ZQuest Classic Coverage Report


Directory: src/
File: src/base/qst.cpp
Date: 2025-05-18 06:19:19
Exec Total Coverage
Lines: 9244 12787 72.3%
Functions: 110 141 78.0%
Branches: 6929 11841 58.5%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/general.h"
4 #include "base/util.h"
5 #include "base/version.h"
6 #include "base/zapp.h"
7 #include "base/qrs.h"
8 #include "base/cpool.h"
9 #include "base/autocombo.h"
10 #include "base/packfile.h"
11 #include "base/dmap.h"
12 #include "base/combo.h"
13 #include "base/msgstr.h"
14 #include "base/flags.h"
15 #include <bit>
16 #include <filesystem>
17 #include <memory>
18 #include <optional>
19 #include <stdio.h>
20 #include <cstring>
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include <assert.h>
25 #include <fmt/format.h>
26
27
28 #include "fmt/core.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "base/qst.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "sfx.h"
38 #include "base/md5.h"
39 #include "zc/replay.h"
40 #include "zc/zelda.h"
41 #include "zinfo.h"
42 #include "zc/ffscript.h"
43 #include "particles.h"
44 #include "dialog/alert.h"
45 #include "base/misctypes.h"
46 #include "base/initdata.h"
47
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern void setZScriptVersion(int32_t s_version);
50
51 static bool read_ext_zinfo = false, read_zinfo = false;
52 static bool loadquest_report = false;
53 static char const* loading_qst_name = NULL;
54 static std::string last_loaded_qstpath;
55 static byte loading_qst_num = 0;
56 static byte subscr_mode = ssdtMAX;
57 // Very old quests only used a byte for combos, and each screen had a "combo page" to vary
58 // what combos were used. This vector just lets us convert those old quests on load.
59 static std::vector<byte> old_combo_pages;
60
61 dword loading_tileset_flags = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 extern int32_t hero_animation_speed; //lower is faster animation
79 extern byte *colordata;
80 extern tiledata *newtilebuf;
81 extern byte *trashbuf;
82 extern itemdata *itemsbuf;
83 extern wpndata *wpnsbuf;
84 extern comboclass *combo_class_buf;
85 extern guydata *guysbuf;
86 extern ZCHEATS zcheats;
87 extern char palnames[MAXLEVELS][17];
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 411 std::map<int32_t, script_slot_data > ffcmap;
92 411 std::map<int32_t, script_slot_data > globalmap;
93 411 std::map<int32_t, script_slot_data > genericmap;
94 411 std::map<int32_t, script_slot_data > itemmap;
95 411 std::map<int32_t, script_slot_data > npcmap;
96 411 std::map<int32_t, script_slot_data > ewpnmap;
97 411 std::map<int32_t, script_slot_data > lwpnmap;
98 411 std::map<int32_t, script_slot_data > playermap;
99 411 std::map<int32_t, script_slot_data > dmapmap;
100 411 std::map<int32_t, script_slot_data > screenmap;
101 411 std::map<int32_t, script_slot_data > itemspritemap;
102 411 std::map<int32_t, script_slot_data > comboscriptmap;
103 411 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 // Each section had a separate, secondary versioning number, but it was never really utilized for
111 // its intended purpose so it's been removed. But we still write something in this field.
112 232 bool write_deprecated_section_cversion(word section_version, PACKFILE* f)
113 {
114 232 return p_iputw(section_version, f);
115 }
116
117 14091 bool read_deprecated_section_cversion(PACKFILE* f)
118 {
119 word unused;
120 14091 return p_igetw(&unused, f);
121 }
122
123 21982 void script_slot_data::update()
124 {
125
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 21978 times.
21982 switch (format)
126 {
127 case SCRIPT_FORMAT_INVALID:
128 4 output = fmt::format("{} --{}", slotname, scriptname);
129 4 break;
130 21978 case SCRIPT_FORMAT_DEFAULT:
131 default:
132 21978 output = fmt::format("{} {}", slotname, scriptname);
133 21978 }
134 21982 }
135
136 char qstdat_string[2048] = { 0 };
137
138 static zinfo* load_tmp_zi = NULL;
139
140 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
141 const byte clavio[9]={97,109,111,110,103,117,115,0};
142
143 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
144 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
145
146 const char *qst_error[] =
147 {
148 "OK","File not found","Invalid quest file",
149 "Version not supported","Obsolete version",
150 "Missing new data" , /* but let it pass in ZQuest */
151 "Internal error occurred", "Invalid password",
152 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
153 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
154 };
155
156 //for legacy quests -DD
157 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
158 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
159 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
160 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
161 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
162 };
163
164 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
165
166
167 char *byte_conversion(int32_t number, int32_t format)
168 {
169 static char num_str[40];
170
171 if(format==-1) //auto
172 {
173 format=1; //bytes
174
175 if(number>1024)
176 {
177 format=2; //kilobytes
178 }
179
180 if(number>1024*1024)
181 {
182 format=3; //megabytes
183 }
184
185 if(number>1024*1024*1024)
186 {
187 format=4; //gigabytes (dude, what are you doing?)
188 }
189 }
190
191 switch(format)
192 {
193 case 1: //bytes
194 sprintf(num_str,"%db",number);
195 break;
196
197 case 2: //kilobytes
198 sprintf(num_str,"%.2fk",float(number)/1024);
199 break;
200
201 case 3: //megabytes
202 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
203 break;
204
205 case 4: //gigabytes
206 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
207 break;
208
209 default:
210 abort();
211 break;
212 }
213
214 return num_str;
215 }
216
217 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
218 {
219 static char num_str1[40];
220 static char num_str2[40];
221 static char num_str[80];
222
223 if(format1==-1) //auto
224 {
225 format1=1; //bytes
226
227 if(number1>1024)
228 {
229 format1=2; //kilobytes
230 }
231
232 if(number1>1024*1024)
233 {
234 format1=3; //megabytes
235 }
236
237 if(number1>1024*1024*1024)
238 {
239 format1=4; //gigabytes (dude, what are you doing?)
240 }
241 }
242
243 if(format2==-1) //auto
244 {
245 format2=1; //bytes
246
247 if(number2>1024)
248 {
249 format2=2; //kilobytes
250 }
251
252 if(number2>1024*1024)
253 {
254 format2=3; //megabytes
255 }
256
257 if(number2>1024*1024*1024)
258 {
259 format2=4; //gigabytes (dude, what are you doing?)
260 }
261 }
262
263 switch(format1)
264 {
265 case 1: //bytes
266 sprintf(num_str1,"%db",number1);
267 break;
268
269 case 2: //kilobytes
270 sprintf(num_str1,"%.2fk",float(number1)/1024);
271 break;
272
273 case 3: //megabytes
274 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
275 break;
276
277 case 4: //gigabytes
278 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
279 break;
280
281 default:
282 abort();
283 break;
284 }
285
286 switch(format2)
287 {
288 case 1: //bytes
289 sprintf(num_str2,"%db",number2);
290 break;
291
292 case 2: //kilobytes
293 sprintf(num_str2,"%.2fk",float(number2)/1024);
294 break;
295
296 case 3: //megabytes
297 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
298 break;
299
300 case 4: //gigabytes
301 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
302 break;
303
304 default:
305 abort();
306 break;
307 }
308
309 sprintf(num_str, "%s/%s", num_str1, num_str2);
310 return num_str;
311 }
312
313 char *ordinal(int32_t num)
314 {
315 static const char *ending[4] = {"st","nd","rd","th"};
316 static char ord_str[8];
317
318 char *end;
319 int32_t t=(num%100)/10;
320 int32_t n=num%10;
321
322 if(n>=1 && n<4 && t!=1)
323 end = (char *)ending[n-1];
324 else
325 end = (char *)ending[3];
326
327 sprintf(ord_str,"%d%s",num%10000,end);
328 return ord_str;
329 }
330
331 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
332 {
333 int32_t ret;
334 *version=0;
335 *build=0;
336 byte temp_map_count=map_count;
337 byte temp_midi_flags[MIDIFLAGS_SIZE];
338 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
339
340 zquestheader tempheader{};
341
342 if(!f)
343 {
344 return qe_invalid;
345 }
346
347 ret=readheader(f, &tempheader);
348
349 if(ret)
350 {
351 return ret;
352 }
353
354 map_count=temp_map_count;
355 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
356 *version=tempheader.zelda_version;
357 *build=tempheader.build;
358 return 0;
359 }
360
361
362 bool find_section(PACKFILE *f, int32_t section_id_requested)
363 {
364
365 if(!f)
366 {
367 return false;
368 }
369
370 int32_t section_id_read;
371 bool catchup=false;
372 word dummy;
373 byte tempbyte;
374 char tempbuf[65536];
375
376
377 switch(section_id_requested)
378 {
379 case ID_RULES:
380 case ID_STRINGS:
381 case ID_MISC:
382 case ID_TILES:
383 case ID_COMBOS:
384 case ID_CSETS:
385 case ID_MAPS:
386 case ID_DMAPS:
387 case ID_DOORS:
388 case ID_ITEMS:
389 case ID_WEAPONS:
390 case ID_COLORS:
391 case ID_ICONS:
392 case ID_INITDATA:
393 case ID_GUYS:
394 case ID_MIDIS:
395 case ID_CHEATS:
396 break;
397
398 default:
399 al_trace("Bad section requested!\n");
400 return false;
401 break;
402 }
403
404 dword section_size;
405
406 //section id
407 if(!p_mgetl(&section_id_read,f))
408 {
409 return false;
410 }
411
412 while(!pack_feof(f))
413 {
414 switch(section_id_read)
415 {
416 case ID_RULES:
417 case ID_STRINGS:
418 case ID_MISC:
419 case ID_TILES:
420 case ID_COMBOS:
421 case ID_CSETS:
422 case ID_MAPS:
423 case ID_DMAPS:
424 case ID_DOORS:
425 case ID_ITEMS:
426 case ID_WEAPONS:
427 case ID_COLORS:
428 case ID_ICONS:
429 case ID_INITDATA:
430 case ID_GUYS:
431 case ID_MIDIS:
432 case ID_CHEATS:
433 catchup=false;
434 break;
435
436 default:
437 break;
438 }
439
440
441 while(catchup)
442 {
443 //section id
444 section_id_read=(section_id_read<<8);
445
446 if(!p_getc(&tempbyte,f))
447 {
448 return false;
449 }
450
451 section_id_read+=tempbyte;
452 }
453
454 if(section_id_read==section_id_requested)
455 {
456 return true;
457 }
458 else
459 {
460 //section version info
461 if(!p_igetw(&dummy,f))
462 {
463 return false;
464 }
465
466 if(!p_igetw(&dummy,f))
467 {
468 return false;
469 }
470
471 //section size
472 if(!p_igetl(&section_size,f))
473 {
474 return false;
475 }
476
477 //pack_fseek(f, section_size);
478 while(section_size>65535)
479 {
480 pfread(tempbuf,65535,f);
481 tempbuf[65535]=0;
482 section_size-=65535;
483 }
484
485 if(section_size>0)
486 {
487 pfread(tempbuf,section_size,f);
488 tempbuf[section_size]=0;
489 }
490 }
491
492 //section id
493 if(!p_mgetl(&section_id_read,f))
494 {
495 return false;
496 }
497 }
498
499 return false;
500 }
501
502
503
504
505
506 bool valid_zqt(PACKFILE *f)
507 {
508
509 //word tiles_used;
510 //word combos_used;
511 //open the file
512 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
513 if(!f)
514 return false;
515
516 //for now, everything else is valid
517 return true;
518
519 /*int16_t version;
520 byte build;
521
522 //read the version and make sure it worked
523 if(!p_igetw(&version,f))
524 {
525 goto error;
526 }
527
528 //read the build and make sure it worked
529 if(!p_getc(&build,f))
530 goto error;
531
532 //read the tile info and make sure it worked
533 if(!p_igetw(&tiles_used,f))
534 {
535 goto error;
536 }
537
538 for (int32_t i=0; i<tiles_used; i++)
539 {
540 if(!pfread(trashbuf,tilesize(tf4Bit),f))
541 {
542 goto error;
543 }
544 }
545
546 //read the combo info and make sure it worked
547 if(!p_igetw(&combos_used,f))
548 {
549 goto error;
550 }
551 for (int32_t i=0; i<combos_used; i++)
552 {
553 if(!pfread(trashbuf,sizeof(newcombo),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the palette info and make sure it worked
560 for (int32_t i=0; i<48; i++)
561 {
562 if(!pfread(trashbuf,newpdTOTAL,f))
563 {
564 goto error;
565 }
566 }
567 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
568 {
569 goto error;
570 }
571 for (int32_t i=0; i<MAXLEVELS; i++)
572 {
573 if(!pfread(trashbuf,PALNAMESIZE,f))
574 {
575 goto error;
576 }
577 }
578
579 //read the sprite info and make sure it worked
580 for (int32_t i=0; i<MAXITEMS; i++)
581 {
582 if(!pfread(trashbuf,sizeof(itemdata),f))
583 {
584 goto error;
585 }
586 }
587
588 for (int32_t i=0; i<MAXWPNS; i++)
589 {
590 if(!pfread(trashbuf,sizeof(wpndata),f))
591 {
592 goto error;
593 }
594 }
595
596 //read the triforce pieces info and make sure it worked
597 for (int32_t i=0; i<8; ++i)
598 {
599 if(!p_getc(&trashbuf,f))
600 {
601 goto error;
602 }
603 }
604
605
606
607 //read the game icons info and make sure it worked
608 for (int32_t i=0; i<4; ++i)
609 {
610 if(!p_igetw(&trashbuf,f))
611 {
612 goto error;
613 }
614 }
615
616 //read the misc colors info and map styles info and make sure it worked
617 if(!pfread(trashbuf,sizeof(zcolors),f))
618 {
619 goto error;
620 }
621
622 //read the template screens and make sure it worked
623 byte num_maps;
624 if(!p_getc(&num_maps,f))
625 {
626 goto error;
627 }
628 for (int32_t i=0; i<TEMPLATES; i++)
629 {
630 if(!pfread(trashbuf,sizeof(mapscr),f))
631 {
632 goto error;
633 }
634 }
635 if (num_maps>1) //dungeon templates
636 {
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f))
640 {
641 goto error;
642 }
643 }
644 }
645
646 //yay! it worked! close the file and say everything was ok.
647 pack_fclose(f);
648 return true;
649
650 error:
651 pack_fclose(f);
652 return false;*/
653 }
654
655 bool valid_zqt(const char *filename)
656 {
657 PACKFILE *f=NULL;
658 bool isvalid;
659 int32_t error;
660 f=open_quest_file(&error, filename, false);
661
662 if(!f)
663 {
664 // setPackfilePassword(NULL);
665 return false;
666 }
667
668 isvalid=valid_zqt(f);
669
670 clear_quest_tmpfile();
671 pack_fclose(f);
672
673 // setPackfilePassword(NULL);
674 return isvalid;
675 }
676
677 /*
678 .qst file history
679
680 .qst files have always been compressed using allegro's packfiles.
681
682 At some point, an encoding layer was added. The two layers look like this:
683
684 1) The top layer is from us. See decode_file_007.
685 [0-24] Preamble "Zelda Classic Quest File"
686 [25-28] Initial decoding seed value.
687 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
688 [last 4] Checksum
689
690 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
691 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
692 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
693 The oldest quests skip the password part.
694
695 Simply, the job of this function is to peel away the top layer.
696
697 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
698 in opening and saving files. There is no version field, so they decryption key is
699 found via trial-by-error (very slow!)
700
701 There are other file types of interest:
702 - .zqt: quest template files, skips top-layer encryption pass
703 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
704 - .qu?: same as above. automated backup files
705 - .qb?: same as above. automated backup files
706 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
707
708 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
709 files are now "slh!.AG ZC Enhanced Quest File".
710 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
711 */
712 779 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
713 {
714
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 if (show_progress)
715 {
716 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
717 }
718
719 779 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
720
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 477 times.
779 if (unencrypted_result.decoded_pf)
721 302 return unencrypted_result.decoded_pf;
722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
477 if (unencrypted_result.not_found)
723 {
724 *open_error = qe_notfound;
725 return nullptr;
726 }
727
728 // Everything below here is legacy code - recently saved quest files will have
729 // returned by now.
730 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
731
732 // Note: although this is primarily for loading .qst files, it can also handle all of the
733 // file types mentioned in the comment above. No need to be told if the file being loaded
734 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
735 477 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
736 477 bool compressed = unencrypted_result.compressed;
737 477 bool encrypted = unencrypted_result.encrypted;
738
739 char tmpfilename[L_tmpnam];
740 477 temp_name(tmpfilename);
741 char percent_done[30];
742 477 int32_t current_method=0;
743
744 PACKFILE *f;
745 477 const char *passwd= encrypted ? datapwd : "";
746
747 // oldquest flag is set when an unencrypted qst file is suspected.
748 477 bool oldquest = false;
749 int32_t ret;
750
751
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 if(strcmp(filename, "default.qst")!=0)
752 {
753 477 box_out(filename);
754 477 }
755 else
756 {
757 box_out("new quest"); // Or whatever
758 }
759 477 box_out("...");
760 477 box_eol();
761 477 box_eol();
762
763
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 if(encrypted)
764 {
765 477 box_out("Decrypting...");
766 477 box_save_x();
767 477 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
768
769
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 63 times.
477 if(ret)
770 {
771
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
772 {
773 case 1:
774 box_out("error.");
775 box_eol();
776 box_end(true);
777 *open_error=qe_notfound;
778 return NULL;
779
780 case 2:
781 box_out("error.");
782 box_eol();
783 box_end(true);
784 *open_error=qe_internal;
785 return NULL;
786 // be sure not to delete tmpfilename now...
787 }
788
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
790 {
791 63 current_method++;
792 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
793 63 box_out(percent_done);
794 63 box_load_x();
795 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
796 63 }
797
798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
799 {
800 63 current_method++;
801 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
802 63 box_out(percent_done);
803 63 box_load_x();
804 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
805 63 }
806
807
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
808 {
809 18 current_method++;
810 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
811 18 box_out(percent_done);
812 18 box_load_x();
813 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
814 18 }
815
816
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
817 {
818 12 current_method++;
819 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
820 12 box_out(percent_done);
821 12 box_load_x();
822 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
823 12 }
824
825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
826 {
827 oldquest = true;
828 passwd="";
829 }
830 63 }
831
832 477 box_out("okay.");
833 477 box_eol();
834 477 }
835 else
836 {
837 oldquest = true;
838 }
839
840 477 box_out("Opening...");
841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
477 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
842
1/2
✓ Branch 0 taken 477 times.
✗ Branch 1 not taken.
477 if(!f)
843 {
844 if((compressed==1)&&(errno==EDOM))
845 {
846 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
847 }
848
849 if(!f)
850 {
851 if(!oldquest)
852 {
853 delete_file(tmpfilename);
854 }
855 box_out("error.");
856 box_eol();
857 box_end(true);
858 *open_error=qe_invalid;
859 return NULL;
860 }
861 }
862
863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
477 if(!oldquest)
864 {
865 477 delete_file(tmpfilename);
866 477 }
867
868 477 box_out("okay.");
869 477 box_eol();
870
871 477 return f;
872 779 }
873
874 PACKFILE *open_quest_template(zquestheader *Header, const char *filename, bool validate)
875 {
876 PACKFILE *f=NULL;
877 int32_t open_error=0;
878
879 if (Header->templatepath[0] != 0)
880 {
881 // TODO: should be safe to remove this, no one seems to use custom quest templates.
882 filename=Header->templatepath;
883 }
884
885 f=open_quest_file(&open_error, filename, false);
886
887 if(!f)
888 {
889 return NULL;
890 }
891
892 if(validate)
893 {
894 if(!valid_zqt(f))
895 {
896 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
897 pack_fclose(f);
898 clear_quest_tmpfile();
899 return NULL;
900 }
901 }
902
903 return f;
904 }
905
906 static bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate, const char* filename)
907 {
908 // The only time the player uses this is to init tiles for some quests 1.90 or older. See readtiles.
909 if (get_app_id() == App::zelda)
910 assert(section_id == ID_TILES);
911
912 combosread=false;
913 mapsread=false;
914 fixffcs=false;
915
916 switch(section_id)
917 {
918 case ID_RULES:
919 case ID_STRINGS:
920 case ID_MISC:
921 case ID_TILES:
922 case ID_COMBOS:
923 case ID_CSETS:
924 case ID_MAPS:
925 case ID_DMAPS:
926 case ID_DOORS:
927 case ID_ITEMS:
928 case ID_WEAPONS:
929 case ID_COLORS:
930 case ID_ICONS:
931 case ID_INITDATA:
932 case ID_GUYS:
933 case ID_MIDIS:
934 case ID_CHEATS:
935 case ID_ITEMDROPSETS:
936 case ID_FAVORITES:
937 break;
938
939 default:
940 return false;
941 break;
942 }
943
944 int32_t ret;
945 word version, build;
946 PACKFILE *f=NULL;
947
948 //why is this here?
949 /*
950 if(colordata==NULL)
951 return false;
952 */
953
954 //setPackfilePassword(datapwd);
955 f=open_quest_template(Header, filename, validate);
956
957 if(!f) //no file, nothing to delete
958 {
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963 ret=get_version_and_build(f, &version, &build);
964
965 if(ret||(version==0))
966 {
967 pack_fclose(f);
968 clear_quest_tmpfile();
969
970 // setPackfilePassword(NULL);
971 return false;
972 }
973
974 if(!find_section(f, section_id))
975 {
976 al_trace("Can't find section!\n");
977 pack_fclose(f);
978 clear_quest_tmpfile();
979
980 //setPackfilePassword(NULL);
981 return false;
982 }
983
984 switch(section_id)
985 {
986 case ID_RULES:
987 //rules
988 ret=readrules(f, Header);
989 break;
990
991 case ID_STRINGS:
992 //strings
993 ret=readstrings(f, Header);
994 break;
995
996 case ID_MISC:
997 //misc data
998 ret=readmisc(f, Header, Misc);
999 break;
1000
1001 case ID_TILES:
1002 //tiles
1003 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1004 break;
1005
1006 case ID_COMBOS:
1007 //combos
1008 clear_combos();
1009 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1010 combosread=true;
1011 break;
1012
1013 case ID_COMBOALIASES:
1014 //combos
1015 ret=readcomboaliases(f, Header, version, build);
1016 break;
1017
1018 case ID_CSETS:
1019 //color data
1020 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1021 break;
1022
1023 case ID_MAPS:
1024 //maps
1025 ret=readmaps(f, Header);
1026 mapsread=true;
1027 break;
1028
1029 case ID_DMAPS:
1030 //dmaps
1031 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1032 break;
1033
1034 case ID_DOORS:
1035 //door combo sets
1036 ret=readdoorcombosets(f, Header);
1037 break;
1038
1039 case ID_ITEMS:
1040 //items
1041 ret=readitems(f, version, build);
1042 break;
1043
1044 case ID_WEAPONS:
1045 //weapons
1046 ret=readweapons(f, Header);
1047 break;
1048
1049 case ID_COLORS:
1050 //misc. colors
1051 ret=readmisccolors(f, Header, Misc);
1052 break;
1053
1054 case ID_ICONS:
1055 //game icons
1056 ret=readgameicons(f, Header, Misc);
1057 break;
1058
1059 case ID_INITDATA:
1060 //initialization data
1061 ret=readinitdata(f, Header);
1062 break;
1063
1064 case ID_GUYS:
1065 //guys
1066 ret=readguys(f, Header);
1067 break;
1068
1069 case ID_MIDIS:
1070 //midis
1071 ret=readtunes(f, Header, tunes);
1072 break;
1073
1074 case ID_CHEATS:
1075 //cheat codes
1076 ret=readcheatcodes(f, Header);
1077 break;
1078
1079 case ID_ITEMDROPSETS:
1080 //item drop sets
1081 // Why is this one commented out?
1082 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1083 break;
1084
1085 case ID_FAVORITES:
1086 // favorite combos and aliases
1087 ret=readfavorites(f, version);
1088 break;
1089
1090 default:
1091 ret=-1;
1092 break;
1093 }
1094
1095 pack_fclose(f);
1096 clear_quest_tmpfile();
1097
1098 //setPackfilePassword(NULL);
1099 if(!ret)
1100 {
1101 return true;
1102 }
1103
1104 return false;
1105 }
1106
1107 bool init_tiles_for_190(bool validate, zquestheader *Header)
1108 {
1109 return init_section(Header, ID_TILES, NULL, NULL, validate, "assets/190_tiles.qst");
1110 }
1111
1112 bool init_tiles(bool validate, zquestheader *Header)
1113 {
1114 return init_section(Header, ID_TILES, NULL, NULL, validate, "modules/classic/default.qst");
1115 }
1116
1117 bool init_combos(bool validate, zquestheader *Header)
1118 {
1119 return init_section(Header, ID_COMBOS, NULL, NULL, validate, "modules/classic/default.qst");
1120 }
1121
1122 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1123 {
1124 return init_section(Header, ID_CSETS, Misc, NULL, validate, "modules/classic/default.qst");
1125 }
1126
1127 779 void init_spritelists()
1128 {
1129
2/2
✓ Branch 0 taken 599 times.
✓ Branch 1 taken 180 times.
779 if(FFCore.quest_format[vZelda] < 0x255)
1130 {
1131 599 guys.setMax(255);
1132 599 items.setMax(255);
1133 599 Ewpns.setMax(255);
1134 599 Lwpns.setMax(255);
1135 599 chainlinks.setMax(255);
1136 599 decorations.setMax(255);
1137 599 particles.setMax(255);
1138 599 }
1139 else
1140 {
1141 180 guys.setMax(255);
1142 180 items.setMax(255);
1143 180 Ewpns.setMax(255);
1144 180 Lwpns.setMax(255);
1145 180 chainlinks.setMax(255);
1146 180 decorations.setMax(255);
1147 180 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1148 }
1149 779 }
1150
1151 304 bool reset_items(bool validate, zquestheader *Header)
1152 {
1153 304 bool ret = true;
1154
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if (get_app_id() == App::zquest)
1155 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate, "modules/classic/default.qst");
1156
1157
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 77824 times.
78128 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 304 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = true;
1172 if (get_app_id() == App::zquest)
1173 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate, "modules/classic/default.qst");
1174
1175 for(int32_t i=0; i<MAXWPNS; i++)
1176 reset_weaponname(i);
1177
1178 return ret;
1179 }
1180
1181 bool reset_mapstyles(bool validate, miscQdata *Misc)
1182 {
1183 Misc->colors.blueframe_tile = 20044;
1184 Misc->colors.blueframe_cset = 0;
1185 Misc->colors.triforce_tile = 23461;
1186 Misc->colors.triforce_cset = 1;
1187 Misc->colors.triframe_tile = 18752;
1188 Misc->colors.triframe_cset = 1;
1189 Misc->colors.overworld_map_tile = 16990;
1190 Misc->colors.overworld_map_cset = 2;
1191 Misc->colors.HCpieces_tile = 21160;
1192 Misc->colors.HCpieces_cset = 8;
1193 Misc->colors.dungeon_map_tile = 19651;
1194 Misc->colors.dungeon_map_cset = 8;
1195 return true;
1196 }
1197
1198 360 int32_t get_qst_buffers()
1199 {
1200 360 TheMaps.resize(MAPSCRS);
1201 360 old_combo_pages.resize(MAPSCRS);
1202 360 map_autolayers.resize(6);
1203
1204 360 Z_message("OK\n");
1205
1206 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1207 // (Shoelace's "Hero of Dreams" uses 1415.)
1208 // So let's be a bit generous and allow 4096 initially.
1209 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1210 // I tested it and it worked without flaw on 6/6/11. - L.
1211 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1212 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1213 // See https://discord.com/channels/876899628556091432/992984989073416242
1214 360 msg_strings_size = 8192;
1215
1216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 360 times.
360 MsgStrings = new MsgStr[msg_strings_size];
1217
1218 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1219
2/2
✓ Branch 0 taken 2949120 times.
✓ Branch 1 taken 360 times.
2949480 for(auto q = 0; q < msg_strings_size; ++q)
1220 {
1221 2949120 MsgStrings[q].clear();
1222 2949120 }
1223
1224
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if((DMaps=new dmap[MAXDMAPS])==NULL)
1225 return 0;
1226
1227
1228
1229 360 combobuf.clear();
1230 360 combobuf.resize(MAXCOMBOS);
1231
1232
1233
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1234 return 0;
1235
1236 360 free_newtilebuf();
1237
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1238 return 0;
1239
1240 360 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1241 //Z_message("Performed memset on tiles\n");
1242 360 clear_tiles(newtilebuf);
1243 //Z_message("Performed clear_tiles()\n");
1244
1245
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 13 times.
360 if (get_app_id() == App::zquest)
1246 {
1247
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1248 return 0;
1249
1250 13 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1251 13 clear_tiles(grabtilebuf);
1252 13 }
1253
1254
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if((trashbuf=(byte*)malloc(100000))==NULL)
1255 return 0;
1256
1257 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1258 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1259 // fixed by ensuring there's actually itemdata there.
1260 // If you change this, be sure to update del_qst_buffers, too.
1261
1262
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1263 return 0;
1264
1265 360 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1266 360 itemsbuf++;
1267
1268
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1269 return 0;
1270
1271 360 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1272
1273
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1274 return 0;
1275
1276 360 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1277
1278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 360 times.
360 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1279 return 0;
1280
1281 360 return 1;
1282 360 }
1283
1284
1285 675 void free_newtilebuf()
1286 {
1287
2/2
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 359 times.
675 if(newtilebuf)
1288 {
1289
2/2
✓ Branch 0 taken 67782000 times.
✓ Branch 1 taken 316 times.
67782316 for(int32_t i=0; i<NEWMAXTILES; i++)
1290
2/2
✓ Branch 0 taken 214500 times.
✓ Branch 1 taken 67567500 times.
135349500 if(newtilebuf[i].data)
1291 67567500 free(newtilebuf[i].data);
1292
1293 316 free(newtilebuf);
1294 316 newtilebuf = 0;
1295 316 }
1296 675 }
1297
1298 315 void free_grabtilebuf()
1299 {
1300
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 11 times.
315 if (get_app_id() == App::zquest)
1301 {
1302
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(grabtilebuf)
1303 {
1304
2/2
✓ Branch 0 taken 2359500 times.
✓ Branch 1 taken 11 times.
2359511 for(int32_t i=0; i<NEWMAXTILES; i++)
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2359500 times.
2359500 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1306
1307 11 free(grabtilebuf);
1308 11 grabtilebuf = 0;
1309 11 }
1310 11 }
1311 315 }
1312
1313 315 void del_qst_buffers()
1314 {
1315
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
✓ Branch 2 taken 315 times.
✗ Branch 3 not taken.
315 if(MsgStrings) delete[] MsgStrings;
1316
1317
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
✓ Branch 2 taken 315 times.
✗ Branch 3 not taken.
315 if (DMaps) delete[] DMaps;
1318
1319 315 combobuf.clear();
1320
1321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 if(colordata) free(colordata);
1322
1323 315 free_newtilebuf();
1324 315 free_grabtilebuf();
1325
1326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 if(trashbuf) free(trashbuf);
1327
1328 // See get_qst_buffers
1329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 if(itemsbuf)
1330 {
1331 315 itemsbuf--;
1332 315 free(itemsbuf);
1333 315 }
1334
1335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 if(wpnsbuf) free(wpnsbuf);
1336
1337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 if(guysbuf) free(guysbuf);
1338
1339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 if(combo_class_buf) free(combo_class_buf);
1340 315 }
1341
1342 18 bool init_palnames()
1343 {
1344 // if(palnames==NULL)
1345 // return false;
1346
1347
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1348 {
1349
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1350 {
1351 case 0:
1352 18 sprintf(palnames[x],"Overworld");
1353 18 break;
1354
1355 case 10:
1356 18 sprintf(palnames[x],"Caves");
1357 18 break;
1358
1359 case 11:
1360 18 sprintf(palnames[x],"Passageways");
1361 18 break;
1362
1363 default:
1364 9162 sprintf(palnames[x],"%c",0);
1365 9162 break;
1366 }
1367 9216 }
1368
1369 18 return true;
1370 }
1371
1372 99615 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1373 {
1374 void *p;
1375
1376
1/2
✓ Branch 0 taken 99615 times.
✗ Branch 1 not taken.
99615 p = _AL_MALLOC(MAX(size, alloc_size));
1377
1378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99615 times.
99615 if(!p)
1379 {
1380 return NULL;
1381 }
1382
1383
1/2
✓ Branch 0 taken 99615 times.
✗ Branch 1 not taken.
99615 if(!pfread(p,size,f))
1384 {
1385 _AL_FREE(p);
1386 return NULL;
1387 }
1388
1389
1/2
✓ Branch 0 taken 99615 times.
✗ Branch 1 not taken.
99615 if(pack_ferror(f))
1390 {
1391 _AL_FREE(p);
1392 return NULL;
1393 }
1394
1395 99615 return p;
1396 99615 }
1397
1398 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1399 static const byte* legacy_skip_flags;
1400
1401 /* read_midi:
1402 * Reads MIDI data from a datafile (this is not the same thing as the
1403 * standard midi file format).
1404 */
1405
1406 10202 static MIDI *read_midi(PACKFILE *f)
1407 {
1408 MIDI *m;
1409 int32_t c;
1410 10202 int16_t divisions=0;
1411 10202 int32_t len=0;
1412
1413 10202 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1414
1415
1/2
✓ Branch 0 taken 10202 times.
✗ Branch 1 not taken.
10202 if(!m)
1416 {
1417 return NULL;
1418 }
1419
1420
2/2
✓ Branch 0 taken 326464 times.
✓ Branch 1 taken 10202 times.
336666 for(c=0; c<MIDI_TRACKS; c++)
1421 {
1422 326464 m->track[c].len = 0;
1423 326464 m->track[c].data = NULL;
1424 326464 }
1425
1426 10202 p_mgetw(&divisions,f);
1427 10202 m->divisions=divisions;
1428
1429
2/2
✓ Branch 0 taken 326464 times.
✓ Branch 1 taken 10202 times.
336666 for(c=0; c<MIDI_TRACKS; c++)
1430 {
1431 326464 p_mgetl(&len,f);
1432 326464 m->track[c].len=len;
1433
1434
2/2
✓ Branch 0 taken 226849 times.
✓ Branch 1 taken 99615 times.
326464 if(m->track[c].len > 0)
1435 {
1436 99615 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1437
1438
1/2
✓ Branch 0 taken 99615 times.
✗ Branch 1 not taken.
99615 if(!m->track[c].data)
1439 {
1440 destroy_midi(m);
1441 return NULL;
1442 }
1443 99615 }
1444 326464 }
1445
1446 LOCK_DATA(m, sizeof(MIDI));
1447
1448
2/2
✓ Branch 0 taken 326464 times.
✓ Branch 1 taken 10202 times.
336666 for(c=0; c<MIDI_TRACKS; c++)
1449 {
1450
2/2
✓ Branch 0 taken 99615 times.
✓ Branch 1 taken 226849 times.
326464 if(m->track[c].data)
1451 {
1452 LOCK_DATA(m->track[c].data, m->track[c].len);
1453 99615 }
1454 326464 }
1455
1456 10202 return m;
1457 10202 }
1458
1459 void clear_combo(int32_t i)
1460 {
1461 combobuf[i].clear();
1462 }
1463
1464 void clear_combos()
1465 {
1466 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1467 clear_combo(tmpcounter);
1468 }
1469
1470 void pack_combos()
1471 {
1472 int32_t di = 0;
1473
1474 for(int32_t si=0; si<1024; si+=2)
1475 combobuf[di++] = combobuf[si];
1476
1477 for(; di<1024; di++)
1478 clear_combo(di);
1479 }
1480
1481 466 void reset_tunes(zctune *tune)
1482 {
1483
2/2
✓ Branch 0 taken 117432 times.
✓ Branch 1 taken 466 times.
117898 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1484 {
1485 117432 tune[i].reset();
1486 117432 }
1487 466 }
1488
1489
1490 /*void reset_midi(zcmidi_ *m)
1491 {
1492 m->title[0]=0;
1493 m->loop=1;
1494 m->volume=144;
1495 m->start=0;
1496 m->loop_start=-1;
1497 m->loop_end=-1;
1498 if(m->midi)
1499 {
1500 destroy_midi(m->midi);
1501 }
1502 m->midi=NULL;
1503 }
1504
1505
1506 void reset_midis(zcmidi_ *m)
1507 {
1508 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1509 {
1510 reset_midi(m+i);
1511 }
1512 }
1513 */
1514
1515 void reset_scr(int32_t scr)
1516 {
1517 /*
1518 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1519 for(unsigned i=0; i<sizeof(mapscr); i++)
1520 *(di++) = 0;
1521 TheMaps[scr].valid=mVERSION;
1522 */
1523
1524 TheMaps[scr].zero_memory();
1525 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1526
1527 for(int32_t i=0; i<6; i++)
1528 {
1529 //these will be uncommented later
1530 //TheMaps[scr].layerxsize[i]=16;
1531 //TheMaps[scr].layerysize[i]=11;
1532 TheMaps[scr].layeropacity[i]=255;
1533 }
1534
1535 TheMaps[scr].valid=mVERSION;
1536
1537 }
1538
1539 int32_t doortranslations_u[9][4]=
1540 {
1541 {37,38,53,54},
1542 {37,38,39,40},
1543 {37,38,55,56},
1544 {37,38,39,40},
1545 {37,38,53,54},
1546 {37,38,53,54},
1547 {37,38,53,54},
1548 {7,8,23,24},
1549 {7,8,41,42}
1550 };
1551
1552 int32_t doortranslations_d[9][4]=
1553 {
1554 {117,118,133,134},
1555 {135,136,133,134},
1556 {119,120,133,134},
1557 {135,136,133,134},
1558 {117,118,133,134},
1559 {117,118,133,134},
1560 {117,118,133,134},
1561 {151,152,167,168},
1562 {137,138,167,168},
1563 };
1564
1565 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1566 int32_t doortranslations_l[9][6]=
1567 {
1568 {66,67,82,83,98,99},
1569 {66,68,82,84,98,100},
1570 {66,69,82,85,98,101},
1571 {66,68,82,84,98,100},
1572 {66,67,82,83,98,99},
1573 {66,67,82,83,98,99},
1574 {66,67,82,83,98,99},
1575 {64,65,80,81,96,97},
1576 {64,65,80,114,96,97},
1577 };
1578
1579 int32_t doortranslations_r[9][6]=
1580 {
1581
1582 {76,77,92,93,108,109},
1583 {75,77,91,93,107,109},
1584 {74,77,90,93,106,109},
1585 {75,77,91,93,107,109},
1586 {76,77,92,93,108,109},
1587 {76,77,92,93,108,109},
1588 {76,77,92,93,108,109},
1589 {78,79,94,95,110,111},
1590 {78,79,125,95,110,111},
1591 };
1592
1593 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1594 {
1595 858450 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1596 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF) + (old_cpage<<8);
1597 }
1598
1599 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1600 {
1601 //these are here to bypass compiler warnings about unused arguments
1602 840750 map=map;
1603 840750 scr=scr;
1604 840750 pos=pos;
1605
1606 //what does this function do?
1607 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1608 840750 return 2;
1609 }
1610
1611 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1612 {
1613
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1614 {
1615 18423 return 0;
1616 }
1617
1618 4425 DoorComboSet tempdcs{};
1619
1620 //up
1621
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1622 {
1623
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1624 {
1625 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1626 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1627 159300 }
1628 39825 }
1629
1630 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1631 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1632 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1633 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1634 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1635 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1636
1637 //down
1638
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1639 {
1640
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1641 {
1642 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1643 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1644 159300 }
1645 39825 }
1646
1647 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1648
1649 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1650 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1651 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1652 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1653 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1654
1655 //left
1656 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1657
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1658 {
1659
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1660 {
1661 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1662 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1663 238950 }
1664 39825 }
1665
1666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1667 {
1668 if((j!=2)&&(j!=3))
1669 {
1670 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1671 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1672 }
1673 }
1674
1675 4425 tempdcs.bombdoorcombo_l[0]=0;
1676 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1677 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1678 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1679 4425 tempdcs.bombdoorcombo_l[2]=0;
1680 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1681 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1682 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1683
1684 //right
1685
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1686 {
1687
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1688 {
1689 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1690 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1691 238950 }
1692 39825 }
1693
1694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1695 {
1696 if((j!=2)&&(j!=3))
1697 {
1698 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1699 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1700 }
1701 }
1702
1703 4425 tempdcs.bombdoorcombo_r[0]=0;
1704 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1705 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1706 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1707 4425 tempdcs.bombdoorcombo_r[2]=0;
1708 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1709 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1710 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1711
1712 int32_t k;
1713
1714
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 10306 times.
10366 for(k=0; k<door_combo_set_count; k++)
1715 {
1716
2/2
✓ Branch 0 taken 5941 times.
✓ Branch 1 taken 4365 times.
10306 if(DoorComboSets[k]==tempdcs)
1717 {
1718 4365 break;
1719 }
1720 5941 }
1721
1722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 if (k >= DoorComboSets.size())
1723 {
1724 return 0;
1725 }
1726
1727
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4365 times.
4425 if(k==door_combo_set_count)
1728 {
1729 60 DoorComboSets[k]=tempdcs;
1730 60 DoorComboSetNames[k] = fmt::format("Door Combo Set {}", k);
1731 60 ++door_combo_set_count;
1732 60 }
1733
1734 4425 return k;
1735 /*
1736 doorcombo_u[9][4];
1737 doorcset_u[9][4];
1738 doorcombo_d[9][4];
1739 doorcset_d[9][4];
1740 doorcombo_l[9][6];
1741 doorcset_l[9][6];
1742 doorcombo_r[9][6];
1743 doorcset_r[9][6];
1744 bombdoorcombo_u[2];
1745 bombdoorcset_u[2];
1746 bombdoorcombo_d[2];
1747 bombdoorcset_d[2];
1748 bombdoorcombo_l[3];
1749 bombdoorcset_l[3];
1750 bombdoorcombo_r[3];
1751 bombdoorcset_r[3];
1752 walkthroughcombo[4];
1753 walkthroughcset[4];
1754 */
1755 22848 }
1756
1757 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1758 {
1759 2924544 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1760 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF) + (old_cpage<<8);
1761 }
1762
1763 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1764 {
1765
1766 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1767 }
1768
1769 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1770 {
1771 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1772 }
1773
1774
1775 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1776 {
1777 char temp_pwd[30];
1778 83 memset(temp_pwd,0,30);
1779
1780
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1781 {
1782 75 memcpy(temp_pwd,encrypted_pwd,30);
1783 75 temp_pwd[29]=0;
1784
1785
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1786 {
1787 2250 temp_pwd[i] -= pwdkey;
1788 2250 int32_t t=pwdkey>>15;
1789 2250 pwdkey = (pwdkey<<1)+t;
1790 2250 }
1791 75 }
1792
1793 83 memcpy(pwd,temp_pwd,30);
1794 83 }
1795
1796
1797 266 bool devpwd()
1798 {
1799 #ifdef _DEBUG
1800 return true;
1801 #endif
1802 #if DEVLEVEL > 3
1803 return true;
1804 #endif
1805
1/2
✓ Branch 0 taken 266 times.
✗ Branch 1 not taken.
266 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1806 }
1807 bool check_questpwd(zquestheader *Header, char *pwd)
1808 {
1809 if(devpwd())
1810 return true;
1811 if((!strcmp(pwd, (char*)clavio)))
1812 return true;
1813 cvs_MD5Context ctx;
1814 uint8_t md5sum[16];
1815
1816 cvs_MD5Init(&ctx);
1817 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1818 cvs_MD5Final(md5sum, &ctx);
1819
1820 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1821 }
1822
1823 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1824 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1825 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1826
1827 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1828 {
1829 char keyfilename[2048];
1830 replace_extension(keyfilename, path, ext, 2047);
1831 if(!exists(keyfilename))
1832 return false;
1833 bool ret = false;
1834
1835 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1836 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1837 char msg[80] = {0};
1838 pfread(msg, 80, fp);
1839 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1840 {
1841 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1842 pack_fclose(fp);
1843 return false;
1844 }
1845 int16_t ver;
1846 byte bld;
1847 p_igetw(&ver, fp);
1848 p_getc(&bld, fp);
1849 pfread(password, QSTPWD_LEN, fp, true);
1850 if(hashed)
1851 {
1852 char unhashed_pw[QSTPWD_LEN] = {0};
1853
1854 char hashmap = 'Z';
1855 hashmap += 'Q';
1856 hashmap += 'U';
1857 hashmap += 'E';
1858 hashmap += 'S';
1859 hashmap += 'T';
1860
1861 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1862 unhashed_pw[q] = password[q] - hashmap;
1863
1864 ret = check_questpwd(Header, unhashed_pw);
1865 }
1866 else ret = check_questpwd(Header, password);
1867 pack_fclose(fp);
1868 zprint2("Found %s Key File '%s' (%s access)\n",
1869 typestr, keyfilename, ret ? "valid" : "invalid");
1870 return ret;
1871 }
1872
1873 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
1874 {
1875 char exedir[PATH_MAX] = {0};
1876 extract_name(path, exedir, FILENAMEALL);
1877 char const* paths[] = {path, exedir};
1878 for(uint keyty : types)
1879 {
1880 if(keyty >= KEYFILE_NUMTY)
1881 continue;
1882 for(char const* p : paths)
1883 {
1884 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
1885 return true;
1886 }
1887 }
1888 return false;
1889 }
1890
1891 424 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
1892 {
1893 424 zprint2("\n");
1894 424 zprint2("[QUEST METADATA]\n");
1895
1/2
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
424 if(path)
1896 424 zprint2("Path: %s\n", path);
1897
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 98 times.
424 if(tempheader.title[0])
1898 326 zprint2("Title: %s\n", tempheader.title);
1899 424 zprint2("ZC Version: %s\n", tempheader.getVerStr());
1900
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 257 times.
424 if(tempheader.new_version_id_date_day)
1901 167 zprint2("ZC Build Date: %d-%d-%d %s %s\n", tempheader.new_version_id_date_year, tempheader.new_version_id_date_month, tempheader.new_version_id_date_day, tempheader.build_timestamp, tempheader.build_timezone);
1902
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 178 times.
424 if(tempheader.version[0])
1903 246 zprint2("Qst Version: %s\n", tempheader.version);
1904
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 98 times.
424 if(tempheader.author[0])
1905 326 zprint2("Author: %s\n", tempheader.author);
1906 424 zprint2("\n");
1907 424 }
1908
1909 791 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
1910 {
1911 int32_t dummy;
1912 791 zquestheader tempheader{};
1913
2/2
✓ Branch 0 taken 779 times.
✓ Branch 1 taken 12 times.
791 tempheader.filename = Header->filename;
1914 char dummybuf[80];
1915 byte temp_map_count;
1916 byte temp_midi_flags[MIDIFLAGS_SIZE];
1917 word version;
1918 char temp_pwd[30], temp_pwd2[30];
1919 int16_t temp_pwdkey;
1920 cvs_MD5Context ctx;
1921 779 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
1922 779 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
1923
1924
1925
1926
2/4
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 779 times.
779 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
1927 {
1928 Z_message("Unable to read header string\n");
1929 return qe_invalid;
1930 }
1931
1932 // check header
1933
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 24 times.
779 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
1934 {
1935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1936 {
1937 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
1938 return qe_invalid;
1939 }
1940 24 }
1941
1942 779 int32_t templatepath_len=0;
1943
1944 779 tempheader.external_zinfo = false;
1945 779 read_zinfo = false;
1946
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 755 times.
779 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
1947 {
1948 byte padding;
1949
1950
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
1951 {
1952 return qe_invalid;
1953 }
1954
1955
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
1956 {
1957 return qe_invalid;
1958 }
1959
1960 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1961
1962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
1963 {
1964 return qe_version;
1965 }
1966
1967 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1968
1969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1970 {
1971 return qe_invalid;
1972 }
1973
1974
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(bad_version(tempheader.zelda_version))
1975 {
1976 return qe_obsolete;
1977 }
1978
1979
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_igetw(&tempheader.internal,f))
1980 {
1981 return qe_invalid;
1982 }
1983
1984
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.quest_number,f))
1985 {
1986 return qe_invalid;
1987 }
1988
1989 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
1990
1991
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[0],2,f))
1992 {
1993 return qe_invalid;
1994 }
1995
1996
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_map_count,f))
1997 {
1998 return qe_invalid;
1999 }
2000
2001 24 FFCore.quest_format[qMapCount] = temp_map_count;
2002
2003
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
2004 {
2005 return qe_invalid;
2006 }
2007
2008
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2009 {
2010 return qe_invalid;
2011 }
2012
2013
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(!pfread(temp_midi_flags,4,f))
2014 {
2015 return qe_invalid;
2016 }
2017
2018
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2019 {
2020 return qe_invalid;
2021 }
2022
2023
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,14,f))
2024 {
2025 return qe_invalid;
2026 }
2027
2028
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[2],2,f))
2029 {
2030 return qe_invalid;
2031 }
2032
2033
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&dummybuf,f))
2034 {
2035 return qe_invalid;
2036 }
2037
2038
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.version,9,f))
2039 {
2040 return qe_invalid;
2041 }
2042
2043
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2044 {
2045 return qe_invalid;
2046 }
2047 // These fields are expected to end in null bytes!
2048 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
2049
2050
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2051 {
2052 return qe_invalid;
2053 }
2054 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2055
2056
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
2057 {
2058 return qe_invalid;
2059 }
2060
2061
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2062 {
2063 return qe_invalid;
2064 }
2065
2066
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_pwd,30,f))
2067 {
2068 return qe_invalid;
2069 }
2070
2071 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2072
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Init(&ctx);
2073
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2074
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2075
2076
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2077 {
2078 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2079 // Not anymore...
2080 memset(tempheader.minver,0,17);
2081 tempheader.build=0;
2082 tempheader.use_keyfile=0;
2083 memset(tempheader.old_foo, 0, 9);
2084 }
2085 else
2086 {
2087
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.minver,9,f))
2088 {
2089 return qe_invalid;
2090 }
2091
2092
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.build,f))
2093 {
2094 return qe_invalid;
2095 }
2096
2097 24 FFCore.quest_format[vBuild] = tempheader.build;
2098
2099
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2100 {
2101 return qe_invalid;
2102 }
2103
2104
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,9,f))
2105 {
2106 return qe_invalid;
2107 }
2108 } // starting at minver
2109
2110
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2111 {
2112 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2113 6 }
2114 else
2115 {
2116
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2117 {
2118 return qe_invalid; // starting at rules3
2119 }
2120
2121
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(tempheader.zelda_version <= 0x190)
2122 {
2123
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_qr(qr_MEANPLACEDTRAPS,0);
2124 12 }
2125 }
2126
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 unpack_qrs();
2127
2128
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2129
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2130 {
2131
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2132
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,(get_qr(qr_BRKBLSHLDS_DEP)));
2133
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_qr(qr_BRKBLSHLDS_DEP,0);
2134 18 }
2135
2136
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2137 {
2138 6 byte *mf=temp_midi_flags;
2139
2140
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2141 {
2142 4 mf=(byte*)dummybuf;
2143 4 }
2144
2145
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2146 {
2147 return qe_invalid; // starting at foo2
2148 }
2149
2150
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2151 {
2152 return qe_invalid; // starting at foo2
2153 }
2154 6 }
2155
2156
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
24 if((tempheader.zelda_version < 0x192)||
2157
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2158 {
2159 18 memset(tempheader.templatepath,0,2048);
2160 18 }
2161 else
2162 {
2163 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2164 {
2165 return qe_invalid;
2166 }
2167 }
2168
2169
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2170
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2171 {
2172 24 tempheader.use_keyfile=0;
2173 24 }
2174 24 }
2175 else
2176 {
2177 //section id
2178
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!p_mgetl(&dummy,f))
2179 {
2180 return qe_invalid;
2181 }
2182
2183 //section version info
2184
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!p_igetw(&version,f))
2185 {
2186 return qe_invalid;
2187 }
2188
2189 755 FFCore.quest_format[vHeader] = version;
2190
2191
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!p_igetw(&dummy,f))
2192 {
2193 return qe_invalid;
2194 }
2195
2196 //section size
2197
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!p_igetl(&dummy,f))
2198 {
2199 return qe_invalid;
2200 }
2201
2202 //finally... section data
2203
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!p_igetw(&tempheader.zelda_version,f))
2204 {
2205 return qe_invalid;
2206 }
2207
2208 755 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2209
2210 //do some quick checking...
2211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
755 if(tempheader.zelda_version > ZELDA_VERSION)
2212 {
2213 return qe_version;
2214 }
2215
2216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
755 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2217 {
2218 return qe_invalid;
2219 }
2220
2221
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 755 times.
755 if(bad_version(tempheader.zelda_version))
2222 {
2223 return qe_obsolete;
2224 }
2225
2226
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!p_getc(&tempheader.build,f))
2227 {
2228 return qe_invalid;
2229 }
2230
2231 755 FFCore.quest_format[vBuild] = tempheader.build;
2232
2233
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 696 times.
755 if(version<3)
2234 {
2235
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!pfread(temp_pwd,30,f))
2236 {
2237 return qe_invalid;
2238 }
2239
2240
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2241 {
2242 return qe_invalid;
2243 }
2244
2245 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2246
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Init(&ctx);
2247
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2248
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2249 59 }
2250 else
2251 {
2252
2/4
✓ Branch 0 taken 696 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 696 times.
696 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2253 {
2254 return qe_invalid;
2255 }
2256 }
2257
2258
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!p_igetw(&tempheader.internal,f))
2259 {
2260 return qe_invalid;
2261 }
2262
2263
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!p_getc(&tempheader.quest_number,f))
2264 {
2265 return qe_invalid;
2266 }
2267
2268 755 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2269
2270 755 size_t versz = version < 8 ? 9 : 16;
2271
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!pfread(tempheader.version,versz,f))
2272 {
2273 return qe_invalid;
2274 }
2275
2276 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2277 //needs to be copied as char[9] or stored as a s.str
2278
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!pfread(tempheader.minver,versz,f))
2279 {
2280 return qe_invalid;
2281 }
2282
2283 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2284
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2285 {
2286 return qe_invalid;
2287 }
2288 755 tempheader.title[sizeof(tempheader.title)-1] = 0;
2289
2290
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2291 {
2292 return qe_invalid;
2293 }
2294 755 tempheader.author[sizeof(tempheader.author)-1] = 0;
2295
2296
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!p_getc(&tempheader.use_keyfile,f))
2297 {
2298 return qe_invalid;
2299 }
2300
2301 /*
2302 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2303 {
2304 return qe_invalid;
2305 }
2306 */
2307
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2308 {
2309 return qe_invalid;
2310 }
2311
2312
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!pfread(&dummybuf,4,f))
2313 {
2314 return qe_invalid;
2315 }
2316
2317
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2318 {
2319 return qe_invalid;
2320 }
2321
2322
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!pfread(dummybuf,14,f))
2323 {
2324 return qe_invalid;
2325 }
2326
2327 755 templatepath_len=sizeof(tempheader.templatepath);
2328
2329
2/2
✓ Branch 0 taken 696 times.
✓ Branch 1 taken 59 times.
755 if(version==1)
2330 {
2331 59 templatepath_len=280;
2332 59 }
2333
2334
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!pfread(tempheader.templatepath,templatepath_len,f))
2335 {
2336 return qe_invalid;
2337 }
2338
2339
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!p_getc(&temp_map_count,f))
2340 {
2341 return qe_invalid;
2342 }
2343
2344
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 575 times.
755 if(version>=4)
2345 {
2346
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetl(&tempheader.version_major,f))
2347 {
2348 return qe_invalid;
2349 }
2350
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetl(&tempheader.version_minor,f))
2351 {
2352 return qe_invalid;
2353 }
2354
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetl(&tempheader.version_patch,f))
2355 {
2356 return qe_invalid;
2357 }
2358
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2359 {
2360 return qe_invalid;
2361 }
2362
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2363 {
2364 return qe_invalid;
2365 }
2366
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetl(&tempheader.new_version_id_beta,f))
2367 {
2368 return qe_invalid;
2369 }
2370
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2371 {
2372 return qe_invalid;
2373 }
2374
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetl(&tempheader.new_version_id_release,f))
2375 {
2376 return qe_invalid;
2377 }
2378
2379 // 2.55 alpha 86 incorrectly used 56 as the second version component. Fix that here.
2380
3/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 136 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
180 if (tempheader.version_major == 2 && tempheader.version_minor == 56 && tempheader.new_version_id_alpha == 86)
2381 tempheader.version_minor = 55;
2382
2383
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2384 {
2385 return qe_invalid;
2386 }
2387
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_getc(&tempheader.new_version_id_date_month,f))
2388 {
2389 return qe_invalid;
2390 }
2391
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_getc(&tempheader.new_version_id_date_day,f))
2392 {
2393 return qe_invalid;
2394 }
2395
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2396 {
2397 return qe_invalid;
2398 }
2399
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2400 {
2401 return qe_invalid;
2402 }
2403
2404
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!pfread(tempheader.new_version_devsig,256,f))
2405 {
2406 return qe_invalid;
2407 }
2408
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2409 strcpy(tempheader.new_version_devsig, "EmilyV99");
2410
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!pfread(tempheader.new_version_compilername,256,f))
2411 {
2412 return qe_invalid;
2413 }
2414
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!pfread(tempheader.new_version_compilerversion,256,f))
2415 {
2416 return qe_invalid;
2417 }
2418
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!pfread(tempheader.product_name,1024,f))
2419 {
2420 return qe_invalid;
2421 }
2422
2423
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_getc(&tempheader.compilerid,f))
2424 {
2425 return qe_invalid;
2426 }
2427
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2428 {
2429 return qe_invalid;
2430 }
2431
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2432 {
2433 return qe_invalid;
2434 }
2435
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2436 {
2437 return qe_invalid;
2438 }
2439
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2440 {
2441 return qe_invalid;
2442 }
2443
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetw(&tempheader.developerid,f))
2444 {
2445 return qe_invalid;
2446 }
2447
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 180 times.
180 if(!pfread(tempheader.made_in_module_name,1024,f))
2448 {
2449 return qe_invalid;
2450 }
2451
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 180 times.
180 if(!pfread(tempheader.build_datestamp,256,f))
2452 {
2453 return qe_invalid;
2454 }
2455
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 180 times.
180 if(!pfread(tempheader.build_timestamp,256,f))
2456 {
2457 return qe_invalid;
2458 }
2459 180 }
2460 else // <4
2461 {
2462 575 tempheader.version_major = 0;
2463 575 tempheader.version_minor = 0;
2464 575 tempheader.version_patch = 0;
2465 575 tempheader.new_version_id_fourth = 0;
2466 575 tempheader.new_version_id_alpha = 0;
2467 575 tempheader.new_version_id_beta = 0;
2468 575 tempheader.new_version_id_gamma = 0;
2469 575 tempheader.new_version_id_release = 0;
2470 575 tempheader.new_version_id_date_year = 0;
2471 575 tempheader.new_version_id_date_month = 0;
2472 575 tempheader.new_version_id_date_day = 0;
2473 575 tempheader.new_version_id_date_hour = 0;
2474 575 tempheader.new_version_id_date_minute = 0;
2475
2476 575 memset(tempheader.new_version_devsig, 0, 256);
2477 575 memset(tempheader.new_version_compilername, 0, 256);
2478 575 memset(tempheader.new_version_compilerversion, 0, 256);
2479 575 memset(tempheader.product_name, 0, 1024);
2480 575 strcpy(tempheader.product_name, "ZQuest Classic");
2481
2482 575 tempheader.compilerid = 0;
2483 575 tempheader.compilerversionnumber_first = 0;
2484 575 tempheader.compilerversionnumber_second = 0;
2485 575 tempheader.compilerversionnumber_third = 0;
2486 575 tempheader.compilerversionnumber_fourth = 0;
2487 575 tempheader.developerid = 0;
2488
2489 575 memset(tempheader.made_in_module_name, 0, 1024);
2490 575 memset(tempheader.build_datestamp, 0, 256);
2491 575 memset(tempheader.build_timestamp, 0, 256);
2492 }
2493
2494
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 575 times.
755 if ( version >= 5 )
2495 {
2496
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!pfread(tempheader.build_timezone,6,f))
2497 {
2498 return qe_invalid;
2499 }
2500 180 }
2501 else // < 5
2502 {
2503 575 memset(tempheader.build_timezone, 0, 6);
2504 }
2505
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 575 times.
755 if ( version >= 6 )
2506 {
2507 byte b;
2508
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_getc(&b,f))
2509 {
2510 return qe_invalid;
2511 }
2512 180 tempheader.external_zinfo = b?true:false;
2513 180 read_zinfo = true;
2514 180 }
2515
2516
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 575 times.
755 if(version >= 7)
2517 {
2518
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2519 {
2520 return qe_invalid;
2521 }
2522 180 }
2523 else
2524 {
2525 575 tempheader.new_version_is_nightly = false;
2526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 if(tempheader.zelda_version < 0x255)
2527 {
2528
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 516 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
575 switch(tempheader.zelda_version)
2529 {
2530 case 0x254:
2531 tempheader.version_major = 2;
2532 tempheader.version_minor = 54;
2533 break;
2534 case 0x250:
2535
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 394 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 28 times.
✓ Branch 15 taken 15 times.
516 switch(tempheader.build)
2536 {
2537 case 19:
2538 tempheader.version_major = 2;
2539 tempheader.version_minor = 50;
2540 tempheader.new_version_id_gamma = 1;
2541 break;
2542 case 20:
2543 tempheader.version_major = 2;
2544 tempheader.version_minor = 50;
2545 tempheader.new_version_id_gamma = 2;
2546 break;
2547 case 21:
2548 tempheader.version_major = 2;
2549 tempheader.version_minor = 50;
2550 tempheader.new_version_id_gamma = 3;
2551 break;
2552 case 22:
2553 tempheader.version_major = 2;
2554 tempheader.version_minor = 50;
2555 tempheader.new_version_id_gamma = 4;
2556 break;
2557 case 23:
2558 tempheader.version_major = 2;
2559 tempheader.version_minor = 50;
2560 tempheader.new_version_id_gamma = 5;
2561 break;
2562 case 24:
2563 33 tempheader.version_major = 2;
2564 33 tempheader.version_minor = 50;
2565 33 tempheader.new_version_id_release = -1;
2566 33 break;
2567 case 25:
2568 tempheader.version_major = 2;
2569 tempheader.version_minor = 50;
2570 tempheader.version_patch = 1;
2571 tempheader.new_version_id_gamma = 1;
2572 break;
2573 case 26:
2574 24 tempheader.version_major = 2;
2575 24 tempheader.version_minor = 50;
2576 24 tempheader.version_patch = 1;
2577 24 tempheader.new_version_id_gamma = 2;
2578 24 break;
2579 case 27:
2580 tempheader.version_major = 2;
2581 tempheader.version_minor = 50;
2582 tempheader.version_patch = 1;
2583 tempheader.new_version_id_gamma = 3;
2584 break;
2585 case 28:
2586 6 tempheader.version_major = 2;
2587 6 tempheader.version_minor = 50;
2588 6 tempheader.version_patch = 1;
2589 6 tempheader.new_version_id_release = -1;
2590 6 break;
2591 case 29:
2592 394 tempheader.version_major = 2;
2593 394 tempheader.version_minor = 50;
2594 394 tempheader.version_patch = 2;
2595 394 tempheader.new_version_id_release = -1;
2596 394 break;
2597 case 30:
2598 tempheader.version_major = 2;
2599 tempheader.version_minor = 50;
2600 tempheader.version_patch = 3;
2601 tempheader.new_version_id_gamma = 1;
2602 break;
2603 case 31:
2604 16 tempheader.version_major = 2;
2605 16 tempheader.version_minor = 53;
2606 16 tempheader.new_version_id_gamma = -1;
2607 16 break;
2608 case 32:
2609 28 tempheader.version_major = 2;
2610 28 tempheader.version_minor = 53;
2611 28 tempheader.new_version_id_release = -1;
2612 28 break;
2613 case 33:
2614 15 tempheader.version_major = 2;
2615 15 tempheader.version_minor = 53;
2616 15 tempheader.version_patch = 1;
2617 15 break;
2618 }
2619 516 break;
2620
2621 case 0x211:
2622 tempheader.version_major = 2;
2623 tempheader.version_minor = 11;
2624 tempheader.new_version_id_beta = tempheader.build;
2625 break;
2626 case 0x210:
2627 59 tempheader.version_major = 2;
2628 59 tempheader.version_minor = 10;
2629 59 tempheader.new_version_id_beta = tempheader.build;
2630 59 break;
2631 }
2632 575 }
2633 }
2634
2635
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 619 times.
755 if (version>=9)
2636 {
2637 136 std::string version_string;
2638
2/4
✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
136 if(!p_getcstr(&version_string, f))
2639 {
2640 return qe_invalid;
2641 }
2642
2643 136 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2644 136 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 }
2646 else
2647 {
2648 619 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2649 }
2650 }
2651
2652
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 767 times.
779 if(printmetadata)
2653 {
2654
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2655 12 }
2656
2657 //{ Version Warning
2658
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 int32_t vercmp = tempheader.compareVer();
2659
3/6
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 779 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 779 times.
✗ Branch 5 not taken.
779 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2660
2/4
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 779 times.
✗ Branch 3 not taken.
779 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2661
4/6
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136 times.
✓ Branch 3 taken 643 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 136 times.
915 if(vercmp > 0 || (!vercmp &&
2662
2/4
✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
136 (astatecmp > 0 || (!astatecmp &&
2663 136 avercmp > 0))))
2664 {
2665 bool r = true;
2666 if(loadquest_report)
2667 {
2668 enter_sys_pal();
2669 AlertDialog("Quest saved in newer version",
2670 "This quest was last saved in a newer version of ZQuest."
2671 " Attempting to load this quest may not work correctly; to"
2672 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2673 "\n\nWould you like to continue loading anyway? (Not recommended)",
2674 [&](bool ret,bool)
2675 {
2676 r = ret;
2677 }).show();
2678 exit_sys_pal();
2679 }
2680 if(!r)
2681 return qe_silenterr;
2682 }
2683
2/4
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 779 times.
✗ Branch 3 not taken.
779 else if(tempheader.compareDate() > 0)
2684 {
2685 bool r = true;
2686 if(loadquest_report)
2687 {
2688 enter_sys_pal();
2689 AlertDialog("Quest saved in newer build",
2690 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2691 " issues loading in this build."
2692 "\n{}"
2693 "\n\nWould you like to continue loading anyway?",
2694 tempheader.getVerCmpStr()),
2695 [&](bool ret,bool)
2696 {
2697 r = ret;
2698 }).show();
2699 exit_sys_pal();
2700 }
2701 if(!r)
2702 return qe_silenterr;
2703 }
2704 //}
2705
2706 779 read_ext_zinfo = tempheader.external_zinfo;
2707
2708
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 *Header = tempheader;
2709 779 map_count=temp_map_count;
2710 779 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2711
2712
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 unpack_qrs();
2713
2714 779 return 0;
2715 803 }
2716
2717 6356 int32_t readrules(PACKFILE *f, zquestheader *Header)
2718 {
2719
2/2
✓ Branch 0 taken 6333 times.
✓ Branch 1 taken 23 times.
6356 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6356 times.
6356 if (should_skip)
2721 return 0;
2722
2723 int32_t dummy;
2724 6356 zquestheader tempheader = *Header;
2725 6356 word s_version=0;
2726 6356 dword compatrule_version=0;
2727
2728
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 5913 times.
6356 if(tempheader.zelda_version >= 0x193)
2729 {
2730 //section version info
2731
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&s_version,f))
2732 {
2733 return qe_invalid;
2734 }
2735
2736 443 FFCore.quest_format[vRules] = s_version;
2737
2738
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&dummy,f))
2739 {
2740 return qe_invalid;
2741 }
2742
2743
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 263 times.
443 if(s_version > 16)
2744 {
2745
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!p_igetl(&compatrule_version,f))
2746 {
2747 return qe_invalid;
2748 }
2749 180 }
2750 443 FFCore.quest_format[vCompatRule] = compatrule_version;
2751
2752 //section size
2753
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetl(&dummy,f))
2754 {
2755 return qe_invalid;
2756 }
2757
2758
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 180 times.
443 if ( s_version < 15 )
2759 {
2760 //finally... section data
2761
2/4
✓ Branch 0 taken 263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 263 times.
✗ Branch 3 not taken.
263 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2762 {
2763 return qe_invalid;
2764 }
2765 263 }
2766 else
2767 {
2768
2769
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2770 {
2771 return qe_invalid;
2772 }
2773
2774 }
2775 443 }
2776
2777 //{ bunch of compat stuff
2778 6356 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2779
2780
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 5890 times.
6356 unpack_qrs();
2781
2782
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<2)
2783 {
2784
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(14,0);
2785
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2786
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(28,0);
2787
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(29,0);
2788
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(30,0);
2789
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(32,0);
2790
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(36,0);
2791
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(49,0);
2792
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(50,0);
2793
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(51,0);
2794
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(68,0);
2795
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(75,0);
2796
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(76,0);
2797
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(98,0);
2798
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(110,0);
2799
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(113,0);
2800
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(116,0);
2801
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(102,0);
2802
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(132,0);
2803 82 }
2804
2805 //Now, do any updates...
2806
3/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
466 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2807 {
2808
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2809
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_REPLACEOPENDOORS, 1);
2810
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDLENSORDER, 1);
2811
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOFAIRYGUYFIRES, 1);
2812
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_TRIGGERSREPEAT, 1);
2813 82 }
2814
2815
3/4
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 443 times.
466 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2816 {
2817
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_WALLFLIERS,1);
2818 23 }
2819
2820
3/4
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 443 times.
466 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2821 {
2822
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOBOMBPALFLASH,1);
2823 23 }
2824
2825
3/4
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 443 times.
466 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2826 {
2827
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOSCROLLCONTINUE,1);
2828 23 }
2829
2830
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(tempheader.zelda_version <= 0x210)
2831 {
2832
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ARROWCLIP,1);
2833 82 }
2834
2835
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 407 times.
466 if(tempheader.zelda_version == 0x210)
2836 {
2837
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2838
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CMBCYCLELAYERS, 0);
2839
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2840 59 }
2841
2842
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(tempheader.zelda_version <= 0x210)
2843 {
2844
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDSTYLEWARP,1);
2845
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_210_WARPRETURN,1);
2846 82 }
2847
2848 //might not be correct
2849
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 443 times.
466 if(tempheader.zelda_version < 0x210)
2850 {
2851
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2852
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDTRIBBLES_DEP,1);
2853
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2854 23 }
2855
2856
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(tempheader.zelda_version < 0x211)
2857 {
2858
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2859 82 }
2860
2861
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 461 times.
466 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2862 {
2863
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 444 times.
466 set_qr(qr_192b163_WARP,1);
2864 22 }
2865
2866
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 47 times.
22 if(tempheader.zelda_version == 0x210)
2867 {
2868
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2869
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2870
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_DMGCOMBOPRI, 0);
2871 59 }
2872
2873
3/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
106 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
2874 {
2875
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 196 times.
278 set_qr(qr_OLDPICKUP,1);
2876 82 }
2877
2878
3/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
466 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
2879 {
2880
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
2881
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
2882 82 }
2883
2884
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
2885 {
2886
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
2887 82 }
2888
2889
4/4
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 262 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 171 times.
466 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
2890 {
2891
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 set_qr(qr_PEAHATCLOCKVULN, 1);
2892 33 }
2893
2894
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 180 times.
466 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
2895 {
2896
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 204 times.
286 set_qr(qr_OLD_DOORREPAIR, 1);
2897 82 }
2898
2899
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 180 times.
262 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
2900 {
2901
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 244 times.
326 set_qr(qr_OLD_SECRETMONEY, 1);
2902 82 }
2903
2904
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 180 times.
262 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
2905 {
2906
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 187 times.
326 set_qr(qr_OLD_POTION_OR_HC, 1);
2907 139 }
2908
2909
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 180 times.
319 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
2910 {
2911
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 130 times.
269 set_qr(qr_OFFSCREENWEAPONS, 1);
2912 139 }
2913
2914 //Bombchu fix.
2915
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 204 times.
319 if(tempheader.zelda_version == 0x250)
2916 {
2917
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 171 times.
204 if ( tempheader.build == 24 ) //2.50.0
2918 {
2919
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2920 33 }
2921
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 198 times.
204 if ( tempheader.build == 28 ) //2.50.1
2922 {
2923
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2924 6 }
2925
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 122 times.
204 if ( tempheader.build == 29 ) //2.50.2
2926 {
2927
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2928 82 }
2929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if ( tempheader.build == 30 ) //2.50.3RC1
2930 {
2931 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2932 }
2933 204 }
2934
2935
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 180 times.
319 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2936 {
2937 // qr_OFFSETEWPNCOLLISIONFIX
2938 // All 'official' quests need this disabled.
2939 // All 2.10 and lower quests need this enabled to preseve compatability.
2940 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
2941
2942 //~Gleeok
2943
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 124 times.
269 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
2944
2945 // Broke in build 695
2946
3/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
145 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
2947
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 set_qr(qr_BROKENSTATUES, 1);
2948 145 }
2949
11/14
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 448 times.
✓ Branch 2 taken 443 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 566 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 566 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 549 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
325 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
2950 {
2951
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
2952 22 }
2953
8/8
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 277 times.
✓ Branch 3 taken 90 times.
✓ Branch 4 taken 195 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 180 times.
✓ Branch 7 taken 15 times.
571 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
2954 {
2955
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 285 times.
556 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
2956 271 }
2957
2958
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 204 times.
286 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
2959 {
2960
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLD_210_WATER, 1);
2961 82 }
2962
2963
4/6
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 180 times.
286 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
2964 {
2965
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 148 times.
138 set_qr(qr_STEP_IS_FLOAT,0);
2966 286 }
2967
2968
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if ( tempheader.zelda_version < 0x250 )
2969 {
2970
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_8WAY_SHOT_SFX_DEP, 1);
2971 82 }
2972
2973
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version < 3)
2974 {
2975
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
2976
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
2977 82 }
2978
2979
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<4)
2980 {
2981
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(10,0);
2982 82 }
2983
2984
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<5)
2985 {
2986
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2987 82 }
2988
2989
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<6)
2990 {
2991
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(46,0);
2992 82 }
2993
2994
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<7) // January 2008
2995 {
2996
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HEARTSREQUIREDFIX,0);
2997
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PUSHBLOCKCSETFIX,1);
2998 82 }
2999
3000
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<8)
3001 {
3002
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(12, 0);
3003 82 }
3004 else
3005 {
3006
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 set_bit(deprecated_rules, 12, 0);
3007 }
3008
3009
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<9) // October 2008
3010 {
3011
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOROPE2FLASH_DEP,0);
3012
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3013
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_GHINI2BLINK_DEP,0);
3014
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PHANTOMGHINI2_DEP,0);
3015 82 }
3016
3017
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<10) // December 2008
3018 {
3019
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOCLOCKS_DEP,0);
3020
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3021 82 }
3022
3023
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<11) // April 2009
3024 {
3025
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SLOWENEMYANIM_DEP,0);
3026 82 }
3027
3028 // This served no purpose.
3029 // if(s_version<12) // December 2009
3030 // {
3031 // set_qr(qr_BRKBLSHLDS_DEP,0);
3032 // set_qr(qr_OLDTRIBBLES_DEP,0);
3033 // }
3034
3035 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3036
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version < 13)
3037 {
3038
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SHOPCHEAT, 1);
3039 82 }
3040
3041 // Not entirely sure this is the best place for this...
3042 //2.50.2 bitmap offset fix
3043 466 memset(extra_rules, 0, EXTRARULES_SIZE);
3044
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 180 times.
466 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3045 {
3046
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 141 times.
286 set_er(er_BITMAPOFFSET, 1);
3047
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 set_qr(qr_BITMAPOFFSETFIX, 1);
3048 145 }
3049 //required because quest templates also used this bit, although
3050 //it never did anything, before. -Z
3051
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 121 times.
325 if ( tempheader.zelda_version == 0x250 )
3052 {
3053
5/6
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 122 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 106 times.
204 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3054 {
3055
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 set_er(er_BITMAPOFFSET, 0);
3056
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 set_qr(qr_BITMAPOFFSETFIX, 0);
3057 98 }
3058 204 }
3059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 325 times.
325 if ( tempheader.zelda_version == 0x254 )
3060 {
3061 set_er(er_BITMAPOFFSET, 0);
3062 set_qr(qr_BITMAPOFFSETFIX, 0);
3063 }
3064
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180 times.
325 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3065 {
3066 set_er(er_BITMAPOFFSET, 0);
3067 set_qr(qr_BITMAPOFFSETFIX, 0);
3068 }
3069 //optimise fast drawing for older versions.
3070
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 145 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
325 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3071 {
3072
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 73 times.
325 set_qr(qr_OLDSPRITEDRAWS, 1);
3073 286 }
3074 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3075 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3076 //older quests can set the rule by hand. We need a new qst.dat again.
3077
4/4
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 180 times.
✓ Branch 3 taken 286 times.
286 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3078 {
3079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 360 times.
360 set_qr(qr_OLDEWPNPARENT, 1);
3080 }
3081
4/4
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 180 times.
✓ Branch 3 taken 286 times.
286 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3082 {
3083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 360 times.
360 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3084 }
3085
4/4
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 180 times.
✓ Branch 3 taken 286 times.
286 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3086 {
3087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 360 times.
360 set_qr(qr_OLDQUESTMISC, 1);
3088 }
3089
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if ( tempheader.zelda_version < 0x254 )
3090 {
3091
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3092
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLDEWPNPARENT, 0);
3093
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLDQUESTMISC, 0);
3094 286 }
3095
3096 //item scripts continue to run
3097
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
286 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3098 {
3099
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 32 times.
318 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3100
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3101
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3102
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3103
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3104
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3105
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3106 286 }
3107
3108
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
286 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3109 {
3110
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 32 times.
318 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3111 286 }
3112
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
286 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3113 {
3114
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 32 times.
318 set_qr(qr_TRACESCRIPTIDS, 0);
3115
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3116
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3117
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_PARSER_250DIVISION,1);
3118
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3119
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3120
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_PARSER_FORCE_INLINE,0);
3121
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_PARSER_BINARY_32BIT,0);
3122
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 278 times.
286 if ( get_qr(qr_SELECTAWPN) )
3123 {
3124
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3125 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3126 //Now they **do**, unless you disable that behaviour.
3127 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3128 //now enable the disable L/R item swap on load.
3129 8 }
3130
3131 286 }
3132
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
286 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3133 {
3134 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3135
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 32 times.
318 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3136 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3137 //animations ending earlier than they should.
3138
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3139 //Enemies would ignore solidity on the top half of combos
3140
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3141 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3142
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3143 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3144
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3145 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3146
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3147 286 }
3148
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if ( tempheader.zelda_version < 0x255 )
3149 {
3150
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_NOFFCWAITDRAW, 1);
3151
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_NOITEMWAITDRAW, 1);
3152
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3153
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3154 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3155 286 }
3156
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
286 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3157 {
3158
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 32 times.
318 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3159 286 }
3160
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
286 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3161 {
3162
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 32 times.
318 set_qr(qr_OLD_PRINTF_ARGS, 1);
3163 286 }
3164
3165
3166
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
286 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3167 {
3168
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 32 times.
318 set_qr(qr_BROKEN_RING_POWER, 1);
3169 286 }
3170
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
286 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3171 {
3172
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 32 times.
318 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3173 286 }
3174
5/6
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148 times.
✓ Branch 5 taken 32 times.
286 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3175 {
3176
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3177 286 }
3178
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
318 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3179 {
3180 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 286 times.
318 if(get_qr(qr_SET_XBUTTON_ITEMS))
3182 set_qr(qr_SET_YBUTTON_ITEMS,1);
3183 286 }
3184
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
286 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3185 {
3186
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 32 times.
318 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3187 286 }
3188
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
286 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3189 {
3190
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 32 times.
318 set_qr(qr_OLD_CHEST_COLLISION,1);
3191 286 }
3192
3193
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if ( tempheader.zelda_version < 0x254 )
3194 {
3195
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3196 286 }
3197 //Sideview spikes in 2.50.0
3198
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 180 times.
286 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3199 {
3200
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 167 times.
306 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3201 139 }
3202 //more 2.50 fixes -Z
3203
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 180 times.
319 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3204 {
3205
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 66 times.
269 set_qr(qr_MELEEMAGICCOST, 0);
3206
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3207
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_OLDMIRRORCOMBOS, 1);
3208
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_BROKENBOOKCOST, 1);
3209
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 set_qr(qr_BROKENCHARINTDRAWING, 1);
3210
3211 227 }
3212
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 407 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
407 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3213 {
3214 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3215 set_qr(qr_MELEEMAGICCOST, 1);
3216 }
3217
3218
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 384 times.
407 if(tempheader.zelda_version < 0x193)
3219 {
3220
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_SHORTDGNWALK, 1);
3221 23 }
3222
3223
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 121 times.
407 if(tempheader.zelda_version < 0x255)
3224 {
3225
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLDINFMAGIC, 1);
3226 286 }
3227
3228
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 325 times.
407 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Hero out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3229 {
3230
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3231 82 }
3232
3233
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
407 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3234 {
3235
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 121 times.
407 set_qr(qr_OLD_F6,1);
3236 286 }
3237
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
286 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3238 {
3239
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 32 times.
318 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3240 286 }
3241
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
286 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3242 {
3243
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 32 times.
318 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3244 286 }
3245
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
286 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3246 {
3247
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 32 times.
318 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3248 286 }
3249 //}
3250
3251
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3252
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3253
3254
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 2) //Old CSet2 Handling
3255
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLDCS2,1);
3256
3257
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3258
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3259
3260
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3261
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3262
3263
3/4
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 82 times.
286 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3264
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3265
3266
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3267
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3268
3269
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3270
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3271
3272
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3273
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3274
3275
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 9)
3276 {
3277 //Hardcoded BS Patras
3278
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_HARDCODED_BS_PATRA,1);
3279 //Hardcoded Patra Inner Eye offsets
3280
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3281 //Broken 'Big enemy' animation style
3282
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3283 //Broken Attribute 31/32
3284
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3285 286 }
3286
3287
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 10) //Shared candle use limits
3288
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3289
3290
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 11) //No cross-screen return points
3291
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLD_RESPAWN_POINTS,1);
3292
3293
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 12)
3294 {
3295 //Old fire trail duration
3296
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3297 //Old Intro String in Ganon Room Behavior
3298
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 286 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
286 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3299
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 else set_qr(qr_GANONINTRO,1);
3300 286 }
3301
3302
2/4
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 286 times.
286 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3303 set_qr(qr_ANONE_NOANIM,1);
3304
3305
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 14) //Old Bridge Combo Behavior
3306
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3307
3308
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 15) //Broken Z3 Animation
3309
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3310
3311
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3312
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3313
3314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 286 times.
286 if(compatrule_version < 17)
3315 {
3316 //Old Quake/DrawYOffset behavior
3317 //set_qr(qr_OLD_DRAWOFFSET,1);
3318 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3319 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3320 286 }
3321
3322
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 18)
3323 {
3324 //Broken DrawScreen Derivative Functions
3325
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3326 //Scrolling Cancels Charge
3327
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3328 286 }
3329
3330
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3331
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3332
3333
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 20)
3334
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3335
3336
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 21)
3337 {
3338
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3339
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3340
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3341
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLD_BUG_NET,1);
3342
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3343 286 }
3344
3345
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 22)
3346
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3347
3348
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 23)
3349
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLD_HALF_MAGIC,1);
3350
3351
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 24)
3352 {
3353
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3354
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3355 286 }
3356
3357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 286 times.
286 if(compatrule_version < 25)
3358 {
3359
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 286 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
286 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3360
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3361
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3362 286 }
3363
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 if(compatrule_version < 26)
3364 {
3365
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3366
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_POLVIRE_NO_SHADOW,1);
3367
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3368 286 }
3369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 286 times.
286 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3370 {
3371
2/2
✓ Branch 0 taken 86086 times.
✓ Branch 1 taken 286 times.
86372 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3372
1/2
✓ Branch 0 taken 86086 times.
✗ Branch 1 not taken.
86086 set_qr(q,0);
3373
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 286 times.
1716 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3374
1/2
✓ Branch 0 taken 1430 times.
✗ Branch 1 not taken.
1430 set_qr(q,0);
3375 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3376 286 }
3377
2/2
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 5 times.
286 if(compatrule_version < 28)
3378
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3379
2/2
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 5 times.
296 if(compatrule_version < 29)
3380
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3381
2/2
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 5 times.
296 if(compatrule_version < 30)
3382 {
3383
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 set_qr(qr_DECO_2_YOFFSET,1);
3384
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 set_qr(qr_SCREENSTATE_80s_BUG,1);
3385 291 }
3386
2/2
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 5 times.
296 if(compatrule_version < 31)
3387 {
3388
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3389
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3390 291 }
3391
2/2
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 5 times.
296 if(compatrule_version < 32)
3392
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3393
2/2
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 5 times.
296 if(compatrule_version < 33)
3394
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 set_qr(qr_NO_LIFT_SPRITE,1);
3395
2/2
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 5 times.
296 if(compatrule_version < 34)
3396 {
3397
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3398
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3399
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3400
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3401 291 }
3402
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 3 times.
296 if(compatrule_version < 35)
3403 {
3404
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3405
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3406 293 }
3407
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 3 times.
296 if(compatrule_version < 36)
3408
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_OLD_SHALLOW_SFX,1);
3409
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 3 times.
296 if(compatrule_version < 37)
3410
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3411
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 3 times.
300 if(compatrule_version < 38)
3412
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3413
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 3 times.
300 if(compatrule_version < 39)
3414
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3415
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 3 times.
300 if(compatrule_version < 40)
3416
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3417
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 1 times.
300 if(compatrule_version < 41)
3418
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKENHITBY,1);
3419
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 1 times.
300 if(compatrule_version < 42)
3420
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3421
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 1 times.
300 if(compatrule_version < 43)
3422
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_BOMB_HITBOXES,1);
3423
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 1 times.
300 if(compatrule_version < 44)
3424
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3425
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 1 times.
300 if(compatrule_version < 45)
3426
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3427
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 1 times.
300 if(compatrule_version < 46)
3428
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3429
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
300 if(compatrule_version < 47)
3430 {
3431
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3432
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3433 303 }
3434
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 48)
3435
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_OLD_GUY_HANDLING,1);
3436
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 49)
3437
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3438
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 50)
3439
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3440
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 51)
3441
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3442
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if (compatrule_version < 52)
3443
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3444
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 53)
3445 {
3446
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_OLD_SUBSCR,1);
3447
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3448
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3449 303 }
3450
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 54)
3451
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3452
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 55)
3453
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3454
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 56)
3455
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3456
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 57)
3457
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3458
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 58)
3459
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3460
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 59)
3461
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3462
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 60)
3463
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3464
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 61)
3465
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3466
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 5 times.
308 if(compatrule_version < 62)
3467
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3468
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 4 times.
308 if(compatrule_version < 63)
3469 {
3470
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_LIFTSWIM,1);
3471
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3472 304 }
3473
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 4 times.
308 if(compatrule_version < 64)
3474
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3475
2/2
✓ Branch 0 taken 329 times.
✓ Branch 1 taken 21 times.
308 if(compatrule_version < 65)
3476
1/2
✓ Branch 0 taken 329 times.
✗ Branch 1 not taken.
329 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3477
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 19 times.
350 if(compatrule_version < 66)
3478
1/2
✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
331 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3479
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 19 times.
350 if(compatrule_version < 67)
3480
1/2
✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
331 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3481
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 19 times.
350 if(compatrule_version < 68)
3482
1/2
✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
331 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3483
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 19 times.
350 if(compatrule_version < 69)
3484
1/2
✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
331 set_qr(qr_SETENEMYWEAPONSOUNDSONWPNCHANGE, 1);
3485
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 19 times.
350 if (compatrule_version < 70)
3486
1/2
✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
331 set_qr(qr_BROKEN_CONVEYORS, 1);
3487
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 19 times.
350 if (compatrule_version < 71)
3488
1/2
✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
331 set_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS, 1);
3489
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 19 times.
350 if (compatrule_version < 72)
3490
1/2
✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
331 set_qr(qr_BROKEN_PUSHBLOCK_FLAG_CLONING, 1);
3491
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 19 times.
350 if (compatrule_version < 73)
3492 {
3493
1/2
✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
331 set_qr(qr_OLD_LANDING_SFX, 1);
3494
1/2
✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
331 set_qr(qr_FIRE_LEVEL_TRIGGERS_ARENT_WEAPONS, 1);
3495 331 }
3496
5/6
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 330 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
350 if (compatrule_version < 74 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 9) < 0))
3497
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 330 times.
1 set_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION, 1);
3498
5/6
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 349 times.
✓ Branch 2 taken 330 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
680 if (compatrule_version < 75 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3499
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 330 times.
1 set_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN, 1);
3500
5/6
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 679 times.
✓ Branch 2 taken 330 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
1010 if (compatrule_version < 76 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3501
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 330 times.
1 set_qr(qr_INVERTED_DARK_COMBO_TRIGGERS, 1);
3502
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 991 times.
1340 if (compatrule_version < 77)
3503
1/2
✓ Branch 0 taken 349 times.
✗ Branch 1 not taken.
349 set_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW, 1);
3504
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 991 times.
1340 if (compatrule_version < 78)
3505
1/2
✓ Branch 0 taken 349 times.
✗ Branch 1 not taken.
349 set_qr(qr_SCRIPTS_SCREEN_DRAW_LIGHT_NO_OFFSET, 1);
3506
3507
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 874 times.
1340 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3508
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 180 times.
466 if (s_version < 16)
3509
1/2
✓ Branch 0 taken 286 times.
✗ Branch 1 not taken.
286 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3510
3511
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 *Header = tempheader;
3512
3513 466 return 0;
3514 12246 }
3515
3516 3956343 void init_msgstr(MsgStr *str)
3517 {
3518
2/4
✓ Branch 0 taken 3956343 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3956343 times.
3956343 str->setFromLegacyEncoding("");
3519 3956343 str->nextstring=0;
3520 3956343 str->tile=0;
3521 3956343 str->cset=0;
3522 3956343 str->trans=false;
3523 3956343 str->font=font_zfont;
3524 3956343 str->y=32;
3525 3956343 str->sfx=18;
3526 3956343 str->listpos=0;
3527 3956343 str->x=24;
3528 3956343 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3529 3956343 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3530 3956343 str->hspace=0;
3531 3956343 str->vspace=0;
3532 3956343 str->stringflags=0;
3533 3956343 str->margins[up] = 8;
3534 3956343 str->margins[down] = 0;
3535 3956343 str->margins[left] = 8;
3536 3956343 str->margins[right] = 8;
3537 3956343 str->portrait_tile = 0;
3538 3956343 str->portrait_cset = 0;
3539 3956343 str->portrait_x = 0;
3540 3956343 str->portrait_y = 0;
3541 3956343 str->portrait_tw = 1;
3542 3956343 str->portrait_th = 1;
3543 3956343 str->shadow_type = 0;
3544 3956343 str->shadow_color = 0;
3545 3956343 str->drawlayer = 6;
3546 3956343 }
3547
3548 466 void init_msgstrings(int32_t start, int32_t end)
3549 {
3550
2/4
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 466 times.
466 if(end <= start || end-start > msg_strings_size)
3551 return;
3552
3553
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 3817472 times.
3817938 for(int32_t i=start; i<end; i++)
3554 {
3555 3817472 init_msgstr(&MsgStrings[i]);
3556 3817472 MsgStrings[i].listpos=i;
3557 3817472 }
3558
3559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if(start==0)
3560 {
3561
2/4
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 466 times.
466 MsgStrings[0].setFromLegacyEncoding("(None)");
3562 466 MsgStrings[0].listpos = 0;
3563 466 }
3564 466 }
3565
3566 467 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3567 {
3568
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 443 times.
467 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3569
3570 467 MsgStr tempMsgString;
3571
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 init_msgstr(&tempMsgString);
3572
3573 467 word temp_msg_count=0;
3574 word temp_expansion[16];
3575 467 memset(temp_expansion, 0, 16*sizeof(word));
3576 467 char buf[8193] = {0};
3577
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 443 times.
467 if(Header->zelda_version < 0x193)
3578 {
3579 byte tempbyte;
3580 24 int32_t strings_to_read=0;
3581
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3582
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3583
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3584
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3585 {
3586 18 strings_to_read=128;
3587 18 temp_msg_count=Header->old_str_count;
3588
3589 // Some sort of string count corruption seems to be common in old quests
3590
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3591 {
3592 temp_msg_count=128;
3593 }
3594 18 }
3595
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3596 {
3597 strings_to_read=255;
3598 temp_msg_count=Header->old_str_count;
3599 }
3600 else
3601 {
3602
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3603 {
3604 return qe_invalid;
3605 }
3606
3607 6 strings_to_read=temp_msg_count;
3608
3609
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3610 {
3611 Z_message("Reallocating string buffer...\n");
3612
3613 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3614 // return qe_nomem;
3615
3616 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3617 delete[] MsgStrings;
3618 MsgStrings = new MsgStr[MAXMSGS];
3619 msg_strings_size = MAXMSGS;
3620 for(auto q = 0; q < msg_strings_size; ++q)
3621 {
3622 MsgStrings[q].clear();
3623 }
3624 }
3625 }
3626
3627 //reset the message strings
3628
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3629
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3630
3631
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3632 {
3633
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3634 2550 tempMsgString.listpos = x;
3635
3636
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3637 {
3638 return qe_invalid;
3639 }
3640
3641 2550 buf[74] = '\0';
3642
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 tempMsgString.setFromLegacyEncoding(buf);
3643
3644
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3645 {
3646 return qe_invalid;
3647 }
3648
3649
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3650
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3651 {
3652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3653
3654
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3655 {
3656 return qe_invalid;
3657 }
3658
3659
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3660 {
3661 return qe_invalid;
3662 }
3663 2304 }
3664 else
3665 {
3666
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3667 {
3668 return qe_invalid;
3669 }
3670
3671
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3672 {
3673 return qe_invalid;
3674 }
3675 }
3676
3677
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3678 {
3679
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3680 2549 }
3681 2550 }
3682 24 }
3683 else
3684 {
3685 int32_t dummy_int;
3686 word s_version;
3687
3688 //section version info
3689
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&s_version,f))
3690 {
3691 return qe_invalid;
3692 }
3693
3694 443 FFCore.quest_format[vStrings] = s_version;
3695
3696
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!read_deprecated_section_cversion(f))
3697 {
3698 return qe_invalid;
3699 }
3700
3701 //section size
3702
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetl(&dummy_int,f))
3703 {
3704 return qe_invalid;
3705 }
3706
3707 //finally... section data
3708
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&temp_msg_count,f))
3709 {
3710 return qe_invalid;
3711 }
3712
3713
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
443 if(temp_msg_count >= msg_strings_size && !should_skip)
3714 {
3715 Z_message("Reallocating string buffer...\n");
3716
3717 delete[] MsgStrings;
3718 MsgStrings = new MsgStr[MAXMSGS];
3719 msg_strings_size = MAXMSGS;
3720 for(auto q = 0; q < msg_strings_size; ++q)
3721 {
3722 MsgStrings[q].clear();
3723 }
3724 }
3725
3726 //reset the message strings
3727
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 180 times.
443 if(s_version < 7)
3728
1/2
✓ Branch 0 taken 263 times.
✗ Branch 1 not taken.
263 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3729
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if (!should_skip)
3730
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 init_msgstrings(0,msg_strings_size);
3731
3732 443 int32_t string_length=(s_version<2)?73:145;
3733
3734
2/2
✓ Branch 0 taken 135854 times.
✓ Branch 1 taken 443 times.
136297 for(int32_t i=0; i<temp_msg_count; i++)
3735 {
3736
1/2
✓ Branch 0 taken 135854 times.
✗ Branch 1 not taken.
135854 init_msgstr(&tempMsgString);
3737 135854 tempMsgString.listpos = i;
3738
2/2
✓ Branch 0 taken 5784 times.
✓ Branch 1 taken 130070 times.
135854 if(s_version > 8)
3739 {
3740
2/4
✓ Branch 0 taken 5784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5784 times.
✗ Branch 3 not taken.
5784 if(!p_igetl(&string_length,f))
3741 {
3742 return qe_invalid;
3743 }
3744 5784 }
3745
3746
2/4
✓ Branch 0 taken 135854 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 135854 times.
135854 if (string_length < 0 || string_length > 8193)
3747 {
3748 return qe_invalid;
3749 }
3750
3751
2/2
✓ Branch 0 taken 135302 times.
✓ Branch 1 taken 552 times.
135854 if (string_length > 0)
3752 {
3753
2/4
✓ Branch 0 taken 135302 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135302 times.
✗ Branch 3 not taken.
135302 if (!pfread(buf, string_length, f))
3754 {
3755 return qe_invalid;
3756 }
3757 135302 }
3758 else
3759 {
3760 552 buf[0] = 0;
3761 }
3762
3763
2/4
✓ Branch 0 taken 135854 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135854 times.
✗ Branch 3 not taken.
135854 if(!p_igetw(&tempMsgString.nextstring,f))
3764 {
3765 return qe_invalid;
3766 }
3767
3768
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 102241 times.
135854 if(s_version<2)
3769 {
3770 33613 buf[72] = '\0';
3771
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33613 times.
33613 tempMsgString.setFromLegacyEncoding(buf);
3772 33613 }
3773 else
3774 {
3775 // June 2008: A bug corrupted the last 4 chars of a string.
3776 // Discard these.
3777
1/2
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
102241 if(s_version<3)
3778 {
3779 for(int32_t j=140; j<144; j++)
3780 {
3781 buf[j] = '\0';
3782 }
3783 }
3784
1/2
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
102241 if(string_length > 8192) string_length = 8192;
3785 102241 buf[string_length]='\0'; //Force-terminate
3786
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102241 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102241 times.
102241 tempMsgString.setFromLegacyEncoding(buf);
3787
3788
2/2
✓ Branch 0 taken 5784 times.
✓ Branch 1 taken 96457 times.
102241 if ( s_version >= 6 )
3789 {
3790
2/4
✓ Branch 0 taken 5784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5784 times.
✗ Branch 3 not taken.
5784 if(!p_igetl(&tempMsgString.tile,f))
3791 {
3792 return qe_invalid;
3793 }
3794 5784 }
3795 else
3796 {
3797
2/4
✓ Branch 0 taken 96457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96457 times.
✗ Branch 3 not taken.
96457 if(!p_igetw(&tempMsgString.tile,f))
3798 {
3799 return qe_invalid;
3800 }
3801 }
3802
3803
2/4
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102241 times.
✗ Branch 3 not taken.
102241 if(!p_getc(&tempMsgString.cset,f))
3804 {
3805 return qe_invalid;
3806 }
3807
3808 byte dummy_char;
3809
3810
2/4
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102241 times.
✗ Branch 3 not taken.
102241 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3811 {
3812 return qe_invalid;
3813 }
3814
3815 102241 tempMsgString.trans=dummy_char!=0;
3816
3817
2/4
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102241 times.
✗ Branch 3 not taken.
102241 if(!p_getc(&tempMsgString.font,f))
3818 {
3819 return qe_invalid;
3820 }
3821
3822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102241 times.
102241 if(s_version < 5)
3823 {
3824 if(!p_getc(&tempMsgString.y,f))
3825 {
3826 return qe_invalid;
3827 }
3828 }
3829 else
3830 {
3831
2/4
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102241 times.
✗ Branch 3 not taken.
102241 if(!p_igetw(&tempMsgString.x,f))
3832 {
3833 return qe_invalid;
3834 }
3835
3836
2/4
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102241 times.
✗ Branch 3 not taken.
102241 if(!p_igetw(&tempMsgString.y,f))
3837 {
3838 return qe_invalid;
3839 }
3840
3841
2/4
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102241 times.
✗ Branch 3 not taken.
102241 if(!p_igetw(&tempMsgString.w,f))
3842 {
3843 return qe_invalid;
3844 }
3845
3846
2/4
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102241 times.
✗ Branch 3 not taken.
102241 if(!p_igetw(&tempMsgString.h,f))
3847 {
3848 return qe_invalid;
3849 }
3850
3851
2/4
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102241 times.
✗ Branch 3 not taken.
102241 if(!p_getc(&tempMsgString.hspace,f))
3852 {
3853 return qe_invalid;
3854 }
3855
3856
2/4
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102241 times.
✗ Branch 3 not taken.
102241 if(!p_getc(&tempMsgString.vspace,f))
3857 {
3858 return qe_invalid;
3859 }
3860
3861
2/4
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102241 times.
✗ Branch 3 not taken.
102241 if(!p_getc(&tempMsgString.stringflags,f))
3862 {
3863 return qe_invalid;
3864 }
3865 }
3866
3867
2/2
✓ Branch 0 taken 96457 times.
✓ Branch 1 taken 5784 times.
102241 if(s_version >= 7)
3868 {
3869
2/2
✓ Branch 0 taken 5784 times.
✓ Branch 1 taken 23136 times.
28920 for(int32_t q = 0; q < 4; ++q)
3870 {
3871
2/4
✓ Branch 0 taken 23136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23136 times.
✗ Branch 3 not taken.
23136 if(!p_getc(&tempMsgString.margins[q],f))
3872 {
3873 return qe_invalid;
3874 }
3875 23136 }
3876
3877
2/4
✓ Branch 0 taken 5784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5784 times.
✗ Branch 3 not taken.
5784 if(!p_igetl(&tempMsgString.portrait_tile,f))
3878 {
3879 return qe_invalid;
3880 }
3881
3882
2/4
✓ Branch 0 taken 5784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5784 times.
✗ Branch 3 not taken.
5784 if(!p_getc(&tempMsgString.portrait_cset,f))
3883 {
3884 return qe_invalid;
3885 }
3886
3887
2/4
✓ Branch 0 taken 5784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5784 times.
✗ Branch 3 not taken.
5784 if(!p_getc(&tempMsgString.portrait_x,f))
3888 {
3889 return qe_invalid;
3890 }
3891
3892
2/4
✓ Branch 0 taken 5784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5784 times.
✗ Branch 3 not taken.
5784 if(!p_getc(&tempMsgString.portrait_y,f))
3893 {
3894 return qe_invalid;
3895 }
3896
3897
2/4
✓ Branch 0 taken 5784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5784 times.
✗ Branch 3 not taken.
5784 if(!p_getc(&tempMsgString.portrait_tw,f))
3898 {
3899 return qe_invalid;
3900 }
3901
3902
2/4
✓ Branch 0 taken 5784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5784 times.
✗ Branch 3 not taken.
5784 if(!p_getc(&tempMsgString.portrait_th,f))
3903 {
3904 return qe_invalid;
3905 }
3906 5784 }
3907
3908
2/2
✓ Branch 0 taken 5784 times.
✓ Branch 1 taken 96457 times.
102241 if(s_version >= 8)
3909 {
3910
2/4
✓ Branch 0 taken 5784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5784 times.
✗ Branch 3 not taken.
5784 if(!p_getc(&tempMsgString.shadow_type,f))
3911 {
3912 return qe_invalid;
3913 }
3914
3915
2/4
✓ Branch 0 taken 5784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5784 times.
✗ Branch 3 not taken.
5784 if(!p_getc(&tempMsgString.shadow_color,f))
3916 {
3917 return qe_invalid;
3918 }
3919 5784 }
3920
3921
2/2
✓ Branch 0 taken 5475 times.
✓ Branch 1 taken 96766 times.
102241 if(s_version >= 10)
3922 {
3923
2/4
✓ Branch 0 taken 5475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5475 times.
✗ Branch 3 not taken.
5475 if(!p_getc(&tempMsgString.drawlayer,f))
3924 {
3925 return qe_invalid;
3926 }
3927 5475 }
3928
3929
2/4
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102241 times.
✗ Branch 3 not taken.
102241 if(!p_getc(&tempMsgString.sfx,f))
3930 {
3931 return qe_invalid;
3932 }
3933
3934
1/2
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
102241 if(s_version>3)
3935 {
3936
2/4
✓ Branch 0 taken 102241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102241 times.
✗ Branch 3 not taken.
102241 if(!p_igetw(&tempMsgString.listpos,f))
3937 {
3938 return qe_invalid;
3939 }
3940 102241 }
3941 }
3942
3943
1/2
✓ Branch 0 taken 135854 times.
✗ Branch 1 not taken.
135854 if (!should_skip)
3944 {
3945
1/2
✓ Branch 0 taken 135854 times.
✗ Branch 1 not taken.
135854 MsgStrings[i].copyAll(tempMsgString);
3946 135854 }
3947 135854 }
3948 }
3949
3950
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 466 times.
467 if (!should_skip)
3951 466 msg_count=temp_msg_count;
3952
3953 467 return 0;
3954 467 }
3955
3956 467 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
3957 {
3958
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 443 times.
467 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
3959
3960
3/4
✓ Branch 0 taken 449 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
473 if((Header->zelda_version < 0x192)||
3961
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 443 times.
449 ((Header->zelda_version == 0x192)&&(Header->build<158)))
3962 {
3963 18 return 0;
3964 }
3965
3966 449 word temp_door_combo_set_count=0;
3967 DoorComboSet tempDoorComboSet;
3968 word dummy_word;
3969 int32_t dummy_long;
3970 byte padding;
3971 449 int32_t s_version = 0;
3972
3973
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 448 times.
449 if (!should_skip)
3974 {
3975 448 DoorComboSets = {};
3976 448 DoorComboSetNames = {};
3977 448 }
3978
3979
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 443 times.
449 if(Header->zelda_version > 0x192)
3980 {
3981 //section version info
3982
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&s_version,f))
3983 {
3984 return qe_invalid;
3985 }
3986
3987 443 FFCore.quest_format[vDoors] = s_version;
3988
3989
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&dummy_word,f))
3990 {
3991 return qe_invalid;
3992 }
3993
3994 //section size
3995
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetl(&dummy_long,f))
3996 {
3997 return qe_invalid;
3998 }
3999 443 }
4000
4001 //finally... section data
4002
1/2
✓ Branch 0 taken 449 times.
✗ Branch 1 not taken.
449 if(!p_igetw(&temp_door_combo_set_count,f))
4003 {
4004 return qe_invalid;
4005 }
4006
4007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 449 times.
449 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
4008 {
4009 return qe_invalid;
4010 }
4011
4012
2/2
✓ Branch 0 taken 5304 times.
✓ Branch 1 taken 449 times.
5753 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4013 {
4014 5304 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4015
4016 //name
4017 char name[21];
4018
1/2
✓ Branch 0 taken 5304 times.
✗ Branch 1 not taken.
5304 if(!pfread(&name,sizeof(name),f))
4019 {
4020 return qe_invalid;
4021 }
4022
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5290 times.
5304 if (!should_skip)
4023 5290 DoorComboSetNames[i] = name;
4024
4025
2/2
✓ Branch 0 taken 5264 times.
✓ Branch 1 taken 40 times.
5304 if(Header->zelda_version < 0x193)
4026 {
4027
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
4028 {
4029 return qe_invalid;
4030 }
4031 40 }
4032
4033 //up door
4034
2/2
✓ Branch 0 taken 47736 times.
✓ Branch 1 taken 5304 times.
53040 for(int32_t j=0; j<9; j++)
4035 {
4036
2/2
✓ Branch 0 taken 190944 times.
✓ Branch 1 taken 47736 times.
238680 for(int32_t k=0; k<4; k++)
4037 {
4038
1/2
✓ Branch 0 taken 190944 times.
✗ Branch 1 not taken.
190944 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4039 {
4040 return qe_invalid;
4041 }
4042 190944 }
4043 47736 }
4044
4045
2/2
✓ Branch 0 taken 47736 times.
✓ Branch 1 taken 5304 times.
53040 for(int32_t j=0; j<9; j++)
4046 {
4047
2/2
✓ Branch 0 taken 190944 times.
✓ Branch 1 taken 47736 times.
238680 for(int32_t k=0; k<4; k++)
4048 {
4049
1/2
✓ Branch 0 taken 190944 times.
✗ Branch 1 not taken.
190944 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4050 {
4051 return qe_invalid;
4052 }
4053 190944 }
4054 47736 }
4055
4056 //down door
4057
2/2
✓ Branch 0 taken 47736 times.
✓ Branch 1 taken 5304 times.
53040 for(int32_t j=0; j<9; j++)
4058 {
4059
2/2
✓ Branch 0 taken 190944 times.
✓ Branch 1 taken 47736 times.
238680 for(int32_t k=0; k<4; k++)
4060 {
4061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190944 times.
190944 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4062 {
4063 return qe_invalid;
4064 }
4065 190944 }
4066 47736 }
4067
4068
2/2
✓ Branch 0 taken 47736 times.
✓ Branch 1 taken 5304 times.
53040 for(int32_t j=0; j<9; j++)
4069 {
4070
2/2
✓ Branch 0 taken 190944 times.
✓ Branch 1 taken 47736 times.
238680 for(int32_t k=0; k<4; k++)
4071 {
4072
1/2
✓ Branch 0 taken 190944 times.
✗ Branch 1 not taken.
190944 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4073 {
4074 return qe_invalid;
4075 }
4076 190944 }
4077 47736 }
4078
4079 //left door
4080
2/2
✓ Branch 0 taken 47736 times.
✓ Branch 1 taken 5304 times.
53040 for(int32_t j=0; j<9; j++)
4081 {
4082
2/2
✓ Branch 0 taken 286416 times.
✓ Branch 1 taken 47736 times.
334152 for(int32_t k=0; k<6; k++)
4083 {
4084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 286416 times.
286416 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4085 {
4086 return qe_invalid;
4087 }
4088 286416 }
4089 47736 }
4090
4091
2/2
✓ Branch 0 taken 47736 times.
✓ Branch 1 taken 5304 times.
53040 for(int32_t j=0; j<9; j++)
4092 {
4093
2/2
✓ Branch 0 taken 286416 times.
✓ Branch 1 taken 47736 times.
334152 for(int32_t k=0; k<6; k++)
4094 {
4095
1/2
✓ Branch 0 taken 286416 times.
✗ Branch 1 not taken.
286416 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4096 {
4097 return qe_invalid;
4098 }
4099 286416 }
4100 47736 }
4101
4102 //right door
4103
2/2
✓ Branch 0 taken 47736 times.
✓ Branch 1 taken 5304 times.
53040 for(int32_t j=0; j<9; j++)
4104 {
4105
2/2
✓ Branch 0 taken 286416 times.
✓ Branch 1 taken 47736 times.
334152 for(int32_t k=0; k<6; k++)
4106 {
4107
1/2
✓ Branch 0 taken 286416 times.
✗ Branch 1 not taken.
286416 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4108 {
4109 return qe_invalid;
4110 }
4111 286416 }
4112 47736 }
4113
4114
2/2
✓ Branch 0 taken 47736 times.
✓ Branch 1 taken 5304 times.
53040 for(int32_t j=0; j<9; j++)
4115 {
4116
2/2
✓ Branch 0 taken 286416 times.
✓ Branch 1 taken 47736 times.
334152 for(int32_t k=0; k<6; k++)
4117 {
4118
1/2
✓ Branch 0 taken 286416 times.
✗ Branch 1 not taken.
286416 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4119 {
4120 return qe_invalid;
4121 }
4122 286416 }
4123 47736 }
4124
4125 //up bomb rubble
4126
2/2
✓ Branch 0 taken 10608 times.
✓ Branch 1 taken 5304 times.
15912 for(int32_t j=0; j<2; j++)
4127 {
4128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10608 times.
10608 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4129 {
4130 return qe_invalid;
4131 }
4132 10608 }
4133
4134
2/2
✓ Branch 0 taken 10608 times.
✓ Branch 1 taken 5304 times.
15912 for(int32_t j=0; j<2; j++)
4135 {
4136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10608 times.
10608 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4137 {
4138 return qe_invalid;
4139 }
4140 10608 }
4141
4142 //down bomb rubble
4143
2/2
✓ Branch 0 taken 10608 times.
✓ Branch 1 taken 5304 times.
15912 for(int32_t j=0; j<2; j++)
4144 {
4145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10608 times.
10608 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4146 {
4147 return qe_invalid;
4148 }
4149 10608 }
4150
4151
2/2
✓ Branch 0 taken 10608 times.
✓ Branch 1 taken 5304 times.
15912 for(int32_t j=0; j<2; j++)
4152 {
4153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10608 times.
10608 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4154 {
4155 return qe_invalid;
4156 }
4157 10608 }
4158
4159 //left bomb rubble
4160
2/2
✓ Branch 0 taken 15912 times.
✓ Branch 1 taken 5304 times.
21216 for(int32_t j=0; j<3; j++)
4161 {
4162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15912 times.
15912 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4163 {
4164 return qe_invalid;
4165 }
4166 15912 }
4167
4168
2/2
✓ Branch 0 taken 15912 times.
✓ Branch 1 taken 5304 times.
21216 for(int32_t j=0; j<3; j++)
4169 {
4170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15912 times.
15912 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4171 {
4172 return qe_invalid;
4173 }
4174 15912 }
4175
4176
2/2
✓ Branch 0 taken 5264 times.
✓ Branch 1 taken 40 times.
5304 if(Header->zelda_version < 0x193)
4177 {
4178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4179 {
4180 return qe_invalid;
4181 }
4182
4183 40 }
4184
4185 //right bomb rubble
4186
2/2
✓ Branch 0 taken 15912 times.
✓ Branch 1 taken 5304 times.
21216 for(int32_t j=0; j<3; j++)
4187 {
4188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15912 times.
15912 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4189 {
4190 return qe_invalid;
4191 }
4192 15912 }
4193
4194
2/2
✓ Branch 0 taken 15912 times.
✓ Branch 1 taken 5304 times.
21216 for(int32_t j=0; j<3; j++)
4195 {
4196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15912 times.
15912 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4197 {
4198 return qe_invalid;
4199 }
4200 15912 }
4201
4202
2/2
✓ Branch 0 taken 5264 times.
✓ Branch 1 taken 40 times.
5304 if(Header->zelda_version < 0x193)
4203 {
4204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4205 {
4206 return qe_invalid;
4207 }
4208 40 }
4209
4210 //walkthrough stuff
4211
2/2
✓ Branch 0 taken 21216 times.
✓ Branch 1 taken 5304 times.
26520 for(int32_t j=0; j<4; j++)
4212 {
4213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21216 times.
21216 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4214 {
4215 return qe_invalid;
4216 }
4217 21216 }
4218
4219
2/2
✓ Branch 0 taken 21216 times.
✓ Branch 1 taken 5304 times.
26520 for(int32_t j=0; j<4; j++)
4220 {
4221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21216 times.
21216 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4222 {
4223 return qe_invalid;
4224 }
4225 21216 }
4226
4227 //flags
4228
2/2
✓ Branch 0 taken 10608 times.
✓ Branch 1 taken 5304 times.
15912 for(int32_t j=0; j<2; j++)
4229 {
4230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10608 times.
10608 if(!p_getc(&tempDoorComboSet.flags[j],f))
4231 {
4232 return qe_invalid;
4233 }
4234 10608 }
4235
4236
2/2
✓ Branch 0 taken 5264 times.
✓ Branch 1 taken 40 times.
5304 if(Header->zelda_version < 0x193)
4237 {
4238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4239 {
4240 return qe_invalid;
4241 }
4242 40 }
4243
4244
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5290 times.
5304 if (!should_skip)
4245 5290 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4246 5304 }
4247
4248
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 448 times.
449 if (!should_skip)
4249 448 door_combo_set_count=temp_door_combo_set_count;
4250
4251 449 return 0;
4252 467 }
4253
4254 9 int32_t count_dmaps()
4255 {
4256 9 int32_t i=MAXDMAPS-1;
4257 9 bool found=false;
4258
4259
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
9 while(i>=0 && !found)
4260 {
4261
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
27 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4262
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4263
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4264 18 found=true;
4265
4266
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t j=0; j<8; j++)
4267 {
4268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(DMaps[i].grid[j]!=0)
4269
4270 found=true;
4271 72 }
4272
4273
5/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
18 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4274 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4275 27 found=true;
4276
4277
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
27 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4278
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4279
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4280
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4281 18 found=true;
4282
4283 if(!found)
4284 {
4285 i--;
4286 }
4287 }
4288
4289 9 return i+1;
4290 }
4291
4292
4293 9 int32_t count_shops(miscQdata *Misc)
4294 {
4295 9 int32_t i=NUM_SHOPS-1,j;
4296 9 bool found=false;
4297
4298
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4299 {
4300 2229 j=2;
4301
4302
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4303 {
4304
3/4
✓ Branch 0 taken 6672 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6672 times.
6677 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4305 {
4306 5 found=true;
4307 5 }
4308 else
4309 {
4310 6672 j--;
4311 }
4312 }
4313
4314
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->shop[i].name[0]!=0)
4315 {
4316 found=true;
4317 }
4318
4319
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4320 {
4321 2224 i--;
4322 2224 }
4323 }
4324
4325 9 return i+1;
4326 }
4327
4328 9 int32_t count_infos(miscQdata *Misc)
4329 {
4330 9 int32_t i=255,j;
4331 9 bool found=false;
4332
4333
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4334 {
4335 2229 j=2;
4336
4337
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4338 {
4339
4/4
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 6672 times.
6677 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4340 {
4341 5 found=true;
4342 5 }
4343 else
4344 {
4345 6672 j--;
4346 }
4347 }
4348
4349
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->info[i].name[0]!=0)
4350 {
4351 found=true;
4352 }
4353
4354
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4355 {
4356 2224 i--;
4357 2224 }
4358 }
4359
4360 9 return i+1;
4361 }
4362
4363 9 int32_t count_warprings(miscQdata *Misc)
4364 {
4365 9 int32_t i=15,j;
4366 9 bool found=false;
4367
4368
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 9 times.
58 while(i>=0 && !found)
4369 {
4370 49 j=7;
4371
4372
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 358 times.
✓ Branch 3 taken 49 times.
407 while(j>=0 && !found)
4373 {
4374
4/4
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 349 times.
358 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4375 {
4376 9 found=true;
4377 9 }
4378 else
4379 {
4380 349 j--;
4381 }
4382 }
4383
4384
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 40 times.
49 if(!found)
4385 {
4386 40 i--;
4387 40 }
4388 }
4389
4390 9 return i+1;
4391 }
4392
4393 9 int32_t count_palcycles(miscQdata *Misc)
4394 {
4395 9 int32_t i=255,j;
4396 9 bool found=false;
4397
4398
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2043 times.
✓ Branch 2 taken 2036 times.
✓ Branch 3 taken 9 times.
2045 while(i>=0 && !found)
4399 {
4400 2036 j=2;
4401
4402
4/4
✓ Branch 0 taken 2029 times.
✓ Branch 1 taken 6101 times.
✓ Branch 2 taken 6094 times.
✓ Branch 3 taken 2036 times.
8130 while(j>=0 && !found)
4403 {
4404
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6087 times.
6094 if(Misc->cycles[i][j].count!=0)
4405 {
4406 7 found=true;
4407 7 }
4408 else
4409 {
4410 6087 j--;
4411 }
4412 }
4413
4414
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2029 times.
2036 if(!found)
4415 {
4416 2029 i--;
4417 2029 }
4418 }
4419
4420 9 return i+1;
4421 }
4422
4423 18088 void clear_screen(mapscr *temp_scr)
4424 {
4425 18088 temp_scr->zero_memory();
4426 18088 }
4427
4428 // NOTE: when modifying this, you need to also update:
4429 // readonedmap, readdmaps, and FFScript::read_dmaps
4430 // (and their associated write functions)
4431 3539 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4432 {
4433
2/2
✓ Branch 0 taken 3515 times.
✓ Branch 1 taken 24 times.
3539 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4434
4435 3539 word dmapstoread=0;
4436 3539 dmap tempDMap;
4437
4438 int32_t dummy;
4439 3539 word s_version=0;
4440 byte padding;
4441
4442 char legacy_title[22];
4443
4444
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 466 times.
3539 if (!should_skip)
4445
2/2
✓ Branch 0 taken 238592 times.
✓ Branch 1 taken 466 times.
239058 for(int32_t i=0; i<max_dmaps; i++)
4446 {
4447
1/2
✓ Branch 0 taken 238592 times.
✗ Branch 1 not taken.
238592 DMaps[start_dmap + i].clear();
4448 238592 sprintf(legacy_title," ");
4449 238592 sprintf(DMaps[start_dmap+i].intro," ");
4450 238592 DMaps[start_dmap+i].type |= dmCAVE;
4451 239058 }
4452
4453
3/4
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 3073 times.
✓ Branch 2 taken 466 times.
✗ Branch 3 not taken.
3539 if (!should_skip && s_version == 21)
4454 Regions = {};
4455
4456 3539 Header->is_z3 = false;
4457
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 443 times.
✓ Branch 3 taken 24 times.
3539 if(!Header || Header->zelda_version > 0x192)
4458 {
4459 //section version info
4460
3/4
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
3515 if(!p_igetw(&s_version,f))
4461 {
4462 return qe_invalid;
4463 }
4464 443 Header->is_z3 = s_version >= 22;
4465
4466 443 FFCore.quest_format[vDMaps] = s_version;
4467
4468
4469
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!read_deprecated_section_cversion(f))
4470 {
4471 return qe_invalid;
4472 }
4473
4474 //section size
4475
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetl(&dummy,f))
4476 {
4477 return qe_invalid;
4478 }
4479
4480 //finally... section data
4481
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&dmapstoread,f))
4482 {
4483 return qe_invalid;
4484 }
4485 443 }
4486 else
4487 {
4488
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4489
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4490 {
4491 18 dmapstoread=32;
4492 18 }
4493
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4494 {
4495 6 dmapstoread=OLDMAXDMAPS;
4496 6 }
4497 else
4498 {
4499 dmapstoread=MAXDMAPS;
4500 }
4501 }
4502
4503
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 384 times.
467 dmapstoread=zc_min(dmapstoread, max_dmaps);
4504
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 384 times.
467 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4505
4506
2/2
✓ Branch 0 taken 213824 times.
✓ Branch 1 taken 467 times.
214291 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4507 {
4508
1/2
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
213824 tempDMap.clear();
4509 213824 sprintf(legacy_title," ");
4510 213824 sprintf(tempDMap.intro," ");
4511
4512
2/4
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213824 times.
✗ Branch 3 not taken.
213824 if(!p_getc(&tempDMap.map,f))
4513 {
4514 return qe_invalid;
4515 }
4516
4517
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 196608 times.
213824 if(s_version <= 4)
4518 {
4519 byte tempbyte;
4520
4521
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4522 {
4523 return qe_invalid;
4524 }
4525
4526 17216 tempDMap.level=(word)tempbyte;
4527 17216 }
4528 else
4529 {
4530
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!p_igetw(&tempDMap.level,f))
4531 {
4532 return qe_invalid;
4533 }
4534 }
4535
4536
2/4
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213824 times.
✗ Branch 3 not taken.
213824 if(!p_getc(&tempDMap.xoff,f))
4537 {
4538 return qe_invalid;
4539 }
4540
4541
2/4
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213824 times.
✗ Branch 3 not taken.
213824 if(!p_getc(&tempDMap.compass,f))
4542 {
4543 return qe_invalid;
4544 }
4545
4546
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 17216 times.
213824 if(s_version > 8) // February 2009
4547 {
4548
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!p_igetw(&tempDMap.color,f))
4549 {
4550 return qe_invalid;
4551 }
4552 196608 }
4553 else
4554 {
4555 byte tempbyte;
4556
4557
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4558 {
4559 return qe_invalid;
4560 }
4561
4562 17216 tempDMap.color = (word)tempbyte;
4563 }
4564
4565
2/4
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213824 times.
✗ Branch 3 not taken.
213824 if(!p_getc(&tempDMap.midi,f))
4566 {
4567 return qe_invalid;
4568 }
4569
4570
2/4
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213824 times.
✗ Branch 3 not taken.
213824 if(!p_getc(&tempDMap.cont,f))
4571 {
4572 return qe_invalid;
4573 }
4574
4575
2/4
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213824 times.
✗ Branch 3 not taken.
213824 if(!p_getc(&tempDMap.type,f))
4576 {
4577 return qe_invalid;
4578 }
4579
4580
4/4
✓ Branch 0 taken 5654 times.
✓ Branch 1 taken 208170 times.
✓ Branch 2 taken 5610 times.
✓ Branch 3 taken 44 times.
219478 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4581
1/2
✓ Branch 0 taken 5654 times.
✗ Branch 1 not taken.
5654 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4582 5610 tempDMap.xoff = 0;
4583
4584
2/2
✓ Branch 0 taken 213824 times.
✓ Branch 1 taken 1710592 times.
1924416 for(int32_t j=0; j<8; j++)
4585 {
4586
2/4
✓ Branch 0 taken 1710592 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1710592 times.
✗ Branch 3 not taken.
1710592 if(!p_getc(&tempDMap.grid[j],f))
4587 {
4588 return qe_invalid;
4589 }
4590 1710592 }
4591
4592
5/6
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 211712 times.
213824 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4593 {
4594
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4595 {
4596 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4597 127 }
4598
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4599
4600
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4601 {
4602
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4603
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4604 18 }
4605
4606 //forgotten -DD
4607
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4608 {
4609 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4610 439 }
4611 576 }
4612 else
4613 {
4614
3/4
✓ Branch 0 taken 213248 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
211712 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4615 {
4616 return qe_invalid;
4617 }
4618
4619
2/2
✓ Branch 0 taken 129792 times.
✓ Branch 1 taken 83456 times.
213248 if(s_version<20)
4620 {
4621
2/4
✓ Branch 0 taken 129792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129792 times.
✗ Branch 3 not taken.
129792 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4622 {
4623 return qe_invalid;
4624 }
4625
1/2
✓ Branch 0 taken 129792 times.
✗ Branch 1 not taken.
129792 tempDMap.title.assign(legacy_title);
4626 129792 }
4627 else
4628 {
4629
2/4
✓ Branch 0 taken 83456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83456 times.
✗ Branch 3 not taken.
83456 if (!p_getwstr(&tempDMap.title, f))
4630 {
4631 return qe_invalid;
4632 }
4633 }
4634
4635
2/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
213248 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4636 {
4637 return qe_invalid;
4638 }
4639
4640
5/8
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 211712 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
213248 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4641 {
4642 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4643 DMaps[i] = tempDMap;
4644
4645 continue;
4646 }
4647
4648
3/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 211712 times.
213248 if(Header && (Header->zelda_version < 0x193))
4649 {
4650
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4651 {
4652 return qe_invalid;
4653 }
4654 1536 }
4655
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 121088 times.
213248 if ( s_version >= 11 )
4656 {
4657
2/4
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92160 times.
✗ Branch 3 not taken.
92160 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4658 {
4659 return qe_invalid;
4660 }
4661 92160 }
4662 else
4663 {
4664
2/4
✓ Branch 0 taken 121088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121088 times.
✗ Branch 3 not taken.
121088 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4665 {
4666 return qe_invalid;
4667 }
4668 }
4669
4670
2/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
213248 if(!p_getc(&tempDMap.minimap_1_cset,f))
4671 {
4672 return qe_invalid;
4673 }
4674
4675
3/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 211712 times.
213248 if(Header && (Header->zelda_version < 0x193))
4676 {
4677
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4678 {
4679 return qe_invalid;
4680 }
4681 1536 }
4682
4683
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 121088 times.
213248 if ( s_version >= 11 )
4684 {
4685
2/4
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92160 times.
✗ Branch 3 not taken.
92160 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4686 {
4687 return qe_invalid;
4688 }
4689 92160 }
4690 else
4691 {
4692
2/4
✓ Branch 0 taken 121088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121088 times.
✗ Branch 3 not taken.
121088 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4693 {
4694 return qe_invalid;
4695 }
4696 }
4697
2/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
213248 if(!p_getc(&tempDMap.minimap_2_cset,f))
4698 {
4699 return qe_invalid;
4700 }
4701
4702
3/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 211712 times.
213248 if(Header && (Header->zelda_version < 0x193))
4703 {
4704
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4705 {
4706 return qe_invalid;
4707 }
4708 1536 }
4709
4710
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 121088 times.
213248 if ( s_version >= 11 )
4711 {
4712
2/4
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92160 times.
✗ Branch 3 not taken.
92160 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4713 {
4714 return qe_invalid;
4715 }
4716 92160 }
4717 else
4718 {
4719
2/4
✓ Branch 0 taken 121088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121088 times.
✗ Branch 3 not taken.
121088 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4720 {
4721 return qe_invalid;
4722 }
4723 }
4724
4725
2/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
213248 if(!p_getc(&tempDMap.largemap_1_cset,f))
4726 {
4727 return qe_invalid;
4728 }
4729
4730
3/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 211712 times.
213248 if(Header && (Header->zelda_version < 0x193))
4731 {
4732
4733
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4734 {
4735 return qe_invalid;
4736 }
4737 1536 }
4738
4739
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 121088 times.
213248 if ( s_version >= 11 )
4740 {
4741
2/4
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92160 times.
✗ Branch 3 not taken.
92160 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4742 {
4743 return qe_invalid;
4744 }
4745 92160 }
4746 else
4747 {
4748
2/4
✓ Branch 0 taken 121088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121088 times.
✗ Branch 3 not taken.
121088 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4749 {
4750 return qe_invalid;
4751 }
4752 }
4753
2/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
213248 if(!p_getc(&tempDMap.largemap_2_cset,f))
4754 {
4755 return qe_invalid;
4756 }
4757
4758
2/4
✓ Branch 0 taken 213248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213248 times.
✗ Branch 3 not taken.
213248 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4759 {
4760 return qe_invalid;
4761 }
4762 }
4763
4764
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 17216 times.
213824 if(s_version>1)
4765 {
4766
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!p_getc(&tempDMap.tmusictrack,f))
4767 {
4768 return qe_invalid;
4769 }
4770
4771
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!p_getc(&tempDMap.active_subscreen,f))
4772 {
4773 return qe_invalid;
4774 }
4775
4776
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!p_getc(&tempDMap.passive_subscreen,f))
4777 {
4778 return qe_invalid;
4779 }
4780 196608 }
4781
4782
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 17216 times.
213824 if(s_version>2)
4783 {
4784 byte di[32];
4785
4786
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!pfread(&di, 32, f)) return qe_invalid;
4787
4788
2/2
✓ Branch 0 taken 50331648 times.
✓ Branch 1 taken 196608 times.
50528256 for(int32_t j=0; j<MAXITEMS; j++)
4789 {
4790
2/2
✓ Branch 0 taken 9200 times.
✓ Branch 1 taken 50322448 times.
50331648 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4791 50322448 else tempDMap.disableditems[j]=0;
4792 50331648 }
4793 196608 }
4794
4795
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 17216 times.
213824 if(s_version >= 6)
4796 {
4797
2/4
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196608 times.
✗ Branch 3 not taken.
196608 if(!p_igetl(&tempDMap.flags,f))
4798 {
4799 return qe_invalid;
4800 }
4801 196608 }
4802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4803 {
4804 char temp;
4805
4806 if(!p_getc(&temp,f))
4807 {
4808 return qe_invalid;
4809 }
4810
4811 tempDMap.flags = temp;
4812 }
4813
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4814 {
4815 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4816 8992 }
4817 else
4818 8224 tempDMap.flags=0;
4819
4820
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 17216 times.
213824 if(s_version<7)
4821 {
4822
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2846 times.
✓ Branch 5 taken 6146 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4823 6146 tempDMap.flags|= dmfVIEWMAP;
4824 17216 }
4825
4826
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 17216 times.
213824 if(s_version<8)
4827 {
4828
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4829 {
4830
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4831 8050 tempDMap.type |= dmCAVE;
4832 8050 }
4833
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4834 {
4835 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4836 2332 }
4837 17216 }
4838
4839
7/8
✓ Branch 0 taken 213824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 211712 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 211712 times.
213824 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4840 213248 && (Header->zelda_version < 0x193))
4841 {
4842
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4843 {
4844 return qe_invalid;
4845 }
4846 1536 }
4847
4848
2/2
✓ Branch 0 taken 121664 times.
✓ Branch 1 taken 92160 times.
213824 if(s_version >= 10)
4849 {
4850
2/4
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92160 times.
✗ Branch 3 not taken.
92160 if(!p_getc(&tempDMap.sideview,f))
4851 {
4852 return qe_invalid;
4853 }
4854 92160 }
4855
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 121664 times.
213824 if(s_version < 10) tempDMap.sideview = 0;
4856
4857 //Dmap Scripts
4858
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 121664 times.
213824 if(s_version >= 12)
4859 {
4860
2/4
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92160 times.
✗ Branch 3 not taken.
92160 if(!p_igetw(&tempDMap.script,f))
4861 {
4862 return qe_invalid;
4863 }
4864
2/2
✓ Branch 0 taken 737280 times.
✓ Branch 1 taken 92160 times.
829440 for ( int32_t q = 0; q < 8; q++ )
4865 {
4866
2/4
✓ Branch 0 taken 737280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 737280 times.
✗ Branch 3 not taken.
737280 if(!p_igetl(&tempDMap.initD[q],f))
4867 {
4868 return qe_invalid;
4869 }
4870 737280 }
4871 92160 }
4872
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 121664 times.
213824 if ( s_version < 12 )
4873 {
4874 121664 tempDMap.script = 0;
4875
2/2
✓ Branch 0 taken 973312 times.
✓ Branch 1 taken 121664 times.
1094976 for ( int32_t q = 0; q < 8; q++ )
4876 {
4877 973312 tempDMap.initD[q] = 0;
4878 973312 }
4879 121664 }
4880
4881
2/2
✓ Branch 0 taken 121664 times.
✓ Branch 1 taken 92160 times.
213824 if(s_version >= 13)
4882 {
4883
2/2
✓ Branch 0 taken 737280 times.
✓ Branch 1 taken 92160 times.
829440 for ( int32_t q = 0; q < 8; q++ )
4884 {
4885
2/2
✓ Branch 0 taken 47923200 times.
✓ Branch 1 taken 737280 times.
48660480 for ( int32_t w = 0; w < 65; w++ )
4886 {
4887
2/4
✓ Branch 0 taken 47923200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47923200 times.
✗ Branch 3 not taken.
47923200 if(!p_getc(&tempDMap.initD_label[q][w],f))
4888 {
4889 return qe_invalid;
4890 }
4891 47923200 }
4892 737280 }
4893 92160 }
4894
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 121664 times.
213824 if ( s_version < 13 )
4895 {
4896 121664 tempDMap.script = 0;
4897
2/2
✓ Branch 0 taken 973312 times.
✓ Branch 1 taken 121664 times.
1094976 for ( int32_t q = 0; q < 8; q++ )
4898 {
4899
2/2
✓ Branch 0 taken 63265280 times.
✓ Branch 1 taken 973312 times.
64238592 for ( int32_t w = 0; w < 65; w++ )
4900 63265280 tempDMap.initD_label[q][w] = 0;
4901 973312 }
4902 121664 }
4903
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 121664 times.
213824 if(s_version >= 14)
4904 {
4905
2/4
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92160 times.
✗ Branch 3 not taken.
92160 if(!p_igetw(&tempDMap.active_sub_script,f))
4906 {
4907 return qe_invalid;
4908 }
4909
2/4
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92160 times.
✗ Branch 3 not taken.
92160 if(!p_igetw(&tempDMap.passive_sub_script,f))
4910 {
4911 return qe_invalid;
4912 }
4913
2/2
✓ Branch 0 taken 737280 times.
✓ Branch 1 taken 92160 times.
829440 for ( int32_t q = 0; q < 8; ++q )
4914 {
4915
2/4
✓ Branch 0 taken 737280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 737280 times.
✗ Branch 3 not taken.
737280 if(!p_igetl(&tempDMap.sub_initD[q],f))
4916 {
4917 return qe_invalid;
4918 }
4919 737280 }
4920
2/2
✓ Branch 0 taken 737280 times.
✓ Branch 1 taken 92160 times.
829440 for(int32_t q = 0; q < 8; ++q)
4921 {
4922
2/2
✓ Branch 0 taken 47923200 times.
✓ Branch 1 taken 737280 times.
48660480 for ( int32_t w = 0; w < 65; ++w )
4923 {
4924
2/4
✓ Branch 0 taken 47923200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47923200 times.
✗ Branch 3 not taken.
47923200 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
4925 {
4926 return qe_invalid;
4927 }
4928 47923200 }
4929 737280 }
4930 92160 }
4931 else
4932 {
4933 121664 tempDMap.active_sub_script = 0;
4934 121664 tempDMap.passive_sub_script = 0;
4935
2/2
✓ Branch 0 taken 973312 times.
✓ Branch 1 taken 121664 times.
1094976 for(int32_t q = 0; q < 8; ++q)
4936 {
4937 973312 tempDMap.sub_initD[q] = 0;
4938
2/2
✓ Branch 0 taken 63265280 times.
✓ Branch 1 taken 973312 times.
64238592 for(int32_t w = 0; w < 65; ++w)
4939 63265280 tempDMap.sub_initD_label[q][w] = 0;
4940 973312 }
4941 }
4942
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 121664 times.
213824 if(s_version >= 15)
4943 {
4944
2/4
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92160 times.
✗ Branch 3 not taken.
92160 if(!p_igetw(&tempDMap.onmap_script,f))
4945 {
4946 return qe_invalid;
4947 }
4948
2/2
✓ Branch 0 taken 737280 times.
✓ Branch 1 taken 92160 times.
829440 for ( int32_t q = 0; q < 8; ++q )
4949 {
4950
2/4
✓ Branch 0 taken 737280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 737280 times.
✗ Branch 3 not taken.
737280 if(!p_igetl(&tempDMap.onmap_initD[q],f))
4951 {
4952 return qe_invalid;
4953 }
4954 737280 }
4955
2/2
✓ Branch 0 taken 737280 times.
✓ Branch 1 taken 92160 times.
829440 for(int32_t q = 0; q < 8; ++q)
4956 {
4957
2/2
✓ Branch 0 taken 47923200 times.
✓ Branch 1 taken 737280 times.
48660480 for ( int32_t w = 0; w < 65; ++w )
4958 {
4959
2/4
✓ Branch 0 taken 47923200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47923200 times.
✗ Branch 3 not taken.
47923200 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
4960 {
4961 return qe_invalid;
4962 }
4963 47923200 }
4964 737280 }
4965 92160 }
4966 else
4967 {
4968 121664 tempDMap.onmap_script = 0;
4969
2/2
✓ Branch 0 taken 973312 times.
✓ Branch 1 taken 121664 times.
1094976 for(int32_t q = 0; q < 8; ++q)
4970 {
4971 973312 tempDMap.onmap_initD[q] = 0;
4972
2/2
✓ Branch 0 taken 63265280 times.
✓ Branch 1 taken 973312 times.
64238592 for(int32_t w = 0; w < 65; ++w)
4973 {
4974 63265280 tempDMap.onmap_initD_label[q][w] = 0;
4975 63265280 }
4976 973312 }
4977 }
4978
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 121664 times.
213824 if(s_version >= 16)
4979 {
4980
2/4
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92160 times.
✗ Branch 3 not taken.
92160 if(!p_igetw(&tempDMap.mirrorDMap,f))
4981 {
4982 return qe_invalid;
4983 }
4984 92160 }
4985 else
4986 {
4987 121664 tempDMap.mirrorDMap = -1;
4988 }
4989
4990 // Enhanced music loop points
4991
2/2
✓ Branch 0 taken 83456 times.
✓ Branch 1 taken 130368 times.
213824 if (s_version >= 18)
4992 {
4993
2/4
✓ Branch 0 taken 83456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83456 times.
✗ Branch 3 not taken.
83456 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
4994 {
4995 return qe_invalid;
4996 }
4997
2/4
✓ Branch 0 taken 83456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83456 times.
✗ Branch 3 not taken.
83456 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
4998 {
4999 return qe_invalid;
5000 }
5001
2/4
✓ Branch 0 taken 83456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83456 times.
✗ Branch 3 not taken.
83456 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5002 {
5003 return qe_invalid;
5004 }
5005
2/4
✓ Branch 0 taken 83456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83456 times.
✗ Branch 3 not taken.
83456 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5006 {
5007 return qe_invalid;
5008 }
5009 83456 }
5010 else
5011 {
5012 130368 tempDMap.tmusic_loop_start = 0;
5013 130368 tempDMap.tmusic_loop_end = 0;
5014 130368 tempDMap.tmusic_xfade_in = 0;
5015 130368 tempDMap.tmusic_xfade_out = 0;
5016 }
5017
5018
2/2
✓ Branch 0 taken 83456 times.
✓ Branch 1 taken 130368 times.
213824 if(s_version >= 19)
5019
2/4
✓ Branch 0 taken 83456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83456 times.
✗ Branch 3 not taken.
83456 if(!p_getc(&tempDMap.overlay_subscreen, f))
5020 return qe_invalid;
5021
5022
2/2
✓ Branch 0 taken 83456 times.
✓ Branch 1 taken 130368 times.
213824 if (s_version >= 20)
5023 {
5024
2/4
✓ Branch 0 taken 83456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83456 times.
✗ Branch 3 not taken.
83456 if (!p_igetl(&tempDMap.intro_string_id, f))
5025 return qe_invalid;
5026 83456 }
5027 else
5028 130368 tempDMap.intro_string_id = 0;
5029
5030
2/2
✓ Branch 0 taken 199488 times.
✓ Branch 1 taken 14336 times.
213824 if(s_version == 21)
5031 {
5032 static regions_data tmp_rd;
5033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14336 times.
14336 regions_data& rd = should_skip ? tmp_rd : Regions[tempDMap.map];
5034
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 14336 times.
129024 for(int32_t j=0; j<8; j++)
5035 {
5036
2/2
✓ Branch 0 taken 917504 times.
✓ Branch 1 taken 114688 times.
1032192 for(int32_t k=0; k<8; k++)
5037 {
5038
2/4
✓ Branch 0 taken 917504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 917504 times.
✗ Branch 3 not taken.
917504 if(!p_getc(&rd.region_ids[j][k],f))
5039 {
5040 return qe_invalid;
5041 }
5042 917504 }
5043 114688 }
5044 14336 }
5045
5046
2/2
✓ Branch 0 taken 213568 times.
✓ Branch 1 taken 256 times.
213824 if (!should_skip)
5047 {
5048
1/2
✓ Branch 0 taken 213568 times.
✗ Branch 1 not taken.
213568 if(loading_tileset_flags & TILESET_CLEARMAPS)
5049 tempDMap.map = 0;
5050
1/2
✓ Branch 0 taken 213568 times.
✗ Branch 1 not taken.
213568 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5051 {
5052 tempDMap.script = 0;
5053 for(int q = 0; q < 8; ++q)
5054 tempDMap.initD[q] = 0;
5055 }
5056
1/2
✓ Branch 0 taken 213568 times.
✗ Branch 1 not taken.
213568 DMaps[i] = tempDMap;
5057 213568 }
5058 213824 }
5059
5060 467 return 0;
5061 6611 }
5062
5063 384 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5064 {
5065 //these are here to bypass compiler warnings about unused arguments
5066 384 Header=Header;
5067
5068 miscQdata temp_misc;
5069 384 word s_version=0;
5070 384 int32_t tempsize=0;
5071 word dummyw;
5072
5073 384 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5074
5075 //section version info
5076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_igetw(&s_version,f))
5077 {
5078 return qe_invalid;
5079 }
5080
5081 384 FFCore.quest_format[vColours] = s_version;
5082
5083 384 al_trace("Misc Colours section version: %d\n", s_version);
5084
5085
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
5086 {
5087 return qe_invalid;
5088 }
5089
5090
5091 //section size
5092
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&tempsize,f))
5093 {
5094 return qe_invalid;
5095 }
5096
5097 //finally... section data
5098 384 readsize=0;
5099
5100
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.text,f))
5101 {
5102 return qe_invalid;
5103 }
5104
5105
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.caption,f))
5106 {
5107 return qe_invalid;
5108 }
5109
5110
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.overw_bg,f))
5111 {
5112 return qe_invalid;
5113 }
5114
5115
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5116 {
5117 return qe_invalid;
5118 }
5119
5120
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5121 {
5122 return qe_invalid;
5123 }
5124
5125
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.cave_fg,f))
5126 {
5127 return qe_invalid;
5128 }
5129
5130
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.bs_dk,f))
5131 {
5132 return qe_invalid;
5133 }
5134
5135
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.bs_goal,f))
5136 {
5137 return qe_invalid;
5138 }
5139
5140
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.compass_lt,f))
5141 {
5142 return qe_invalid;
5143 }
5144
5145
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.compass_dk,f))
5146 {
5147 return qe_invalid;
5148 }
5149
5150
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5151 {
5152 return qe_invalid;
5153 }
5154
5155
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.triframe_color,f))
5156 {
5157 return qe_invalid;
5158 }
5159
5160
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.hero_dot,f))
5161 {
5162 return qe_invalid;
5163 }
5164
5165
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5166 {
5167 return qe_invalid;
5168 }
5169
5170
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5171 {
5172 return qe_invalid;
5173 }
5174
5175
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5176 {
5177 return qe_invalid;
5178 }
5179
5180
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5181 {
5182 return qe_invalid;
5183 }
5184
5185
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5186 {
5187 return qe_invalid;
5188 }
5189
5190
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5191 {
5192 return qe_invalid;
5193 }
5194
5195
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5196 {
5197 return qe_invalid;
5198 }
5199
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 204 times.
384 if(s_version < 4)
5200 {
5201
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_igetw(&dummyw,f))
5202 return qe_invalid;
5203 204 temp_misc.colors.triforce_tile = dummyw;
5204
5205
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_igetw(&dummyw,f))
5206 return qe_invalid;
5207 204 temp_misc.colors.triframe_tile = dummyw;
5208
5209
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_igetw(&dummyw,f))
5210 return qe_invalid;
5211 204 temp_misc.colors.overworld_map_tile = dummyw;
5212
5213
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_igetw(&dummyw,f))
5214 return qe_invalid;
5215 204 temp_misc.colors.dungeon_map_tile = dummyw;
5216
5217
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_igetw(&dummyw,f))
5218 return qe_invalid;
5219 204 temp_misc.colors.blueframe_tile = dummyw;
5220
5221
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_igetw(&dummyw,f))
5222 return qe_invalid;
5223 204 temp_misc.colors.HCpieces_tile = dummyw;
5224 204 }
5225
5226
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5227 {
5228 return qe_invalid;
5229 }
5230
5231
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5232 {
5233 return qe_invalid;
5234 }
5235
5236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(s_version < 2)
5237 {
5238 temp_misc.colors.msgtext = 0x01;
5239 }
5240 else
5241 {
5242
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_misc.colors.msgtext, f))
5243 {
5244 return qe_invalid;
5245 }
5246 }
5247
5248
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 180 times.
384 if ( s_version >= 3 ) //expanded tile pages to 825
5249 {
5250
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5251 {
5252 return qe_invalid;
5253 }
5254
5255
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5256 {
5257 return qe_invalid;
5258 }
5259
5260
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5261 {
5262 return qe_invalid;
5263 }
5264
5265
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5266 {
5267 return qe_invalid;
5268 }
5269
5270
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5271 {
5272 return qe_invalid;
5273 }
5274
5275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5276 {
5277 return qe_invalid;
5278 }
5279 180 }
5280
5281 384 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5282
5283 384 return 0;
5284 384 }
5285
5286 384 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5287 {
5288 miscQdata temp_misc;
5289 384 word s_version=0;
5290 byte icons;
5291 384 int32_t tempsize=0;
5292
5293 384 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5294
5295 //section version info
5296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_igetw(&s_version,f))
5297 {
5298 return qe_invalid;
5299 }
5300
5301 384 FFCore.quest_format[vIcons] = s_version;
5302
5303
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
5304 {
5305 return qe_invalid;
5306 }
5307
5308
5309 //section size
5310
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&tempsize,f))
5311 {
5312 return qe_invalid;
5313 }
5314
5315 //finally... section data
5316 384 readsize=0;
5317
5318 384 icons=4;
5319
5320
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 204 times.
384 if ( s_version >= 10 )
5321 {
5322
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t i=0; i<icons; i++)
5323 {
5324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_igetl(&temp_misc.icons[i],f))
5325 {
5326 return qe_invalid;
5327 }
5328 720 }
5329 180 }
5330 else
5331 {
5332
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int32_t i=0; i<icons; i++)
5333 {
5334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 816 times.
816 if(!p_igetw(&temp_misc.icons[i],f))
5335 {
5336 return qe_invalid;
5337 }
5338 816 }
5339 }
5340
5341 384 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5342
5343 384 return 0;
5344 384 }
5345
5346 779 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5347 {
5348
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 755 times.
779 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5349
5350 779 word maxinfos=256;
5351 779 word maxshops=256;
5352 779 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5353 779 word ponds=16, pondsize=72, expansionsize=98*2;
5354 byte tempbyte, padding;
5355 miscQdata temp_misc;
5356 779 word s_version=0;
5357 word swaptmp;
5358 779 int32_t tempsize=0;
5359
5360 779 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5361
5362
2/2
✓ Branch 0 taken 199424 times.
✓ Branch 1 taken 779 times.
200203 for(int32_t i=0; i<maxshops; ++i)
5363 {
5364 199424 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5365 199424 }
5366
5367
2/2
✓ Branch 0 taken 199424 times.
✓ Branch 1 taken 779 times.
200203 for(int32_t i=0; i<maxinfos; ++i)
5368 {
5369 199424 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5370 199424 }
5371
5372 779 memset(&temp_misc.warp, 0, sizeof(temp_misc.warp));
5373
5374
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 755 times.
779 if(Header->zelda_version > 0x192)
5375 {
5376 //section version info
5377
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(!p_igetw(&s_version,f))
5378 {
5379 return qe_invalid;
5380 }
5381
5382 755 FFCore.quest_format[vMisc] = s_version;
5383
5384
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(!read_deprecated_section_cversion(f))
5385 {
5386 return qe_invalid;
5387 }
5388
5389
5390 //section size
5391
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(!p_igetl(&tempsize,f))
5392 {
5393 return qe_invalid;
5394 }
5395 755 }
5396
5397 //finally... section data
5398 779 readsize=0;
5399
5400 //shops
5401
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 755 times.
779 if(Header->zelda_version > 0x192)
5402 {
5403
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(!p_igetw(&shops,f))
5404 {
5405 return qe_invalid;
5406 }
5407 755 }
5408
5409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779 times.
779 if (shops > NUM_SHOPS)
5410 {
5411 return qe_invalid;
5412 }
5413
5414
2/2
✓ Branch 0 taken 10671 times.
✓ Branch 1 taken 779 times.
11450 for(int32_t i=0; i<shops; i++)
5415 {
5416
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9471 times.
10671 if(s_version > 6)
5417 {
5418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9471 times.
9471 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5419 {
5420 return qe_invalid;
5421 }
5422 9471 }
5423
5424
2/2
✓ Branch 0 taken 32013 times.
✓ Branch 1 taken 10671 times.
42684 for(int32_t j=0; j<3; j++)
5425 {
5426
1/2
✓ Branch 0 taken 32013 times.
✗ Branch 1 not taken.
32013 if(!p_getc(&temp_misc.shop[i].item[j],f))
5427 {
5428 return qe_invalid;
5429 }
5430
5431
2/2
✓ Branch 0 taken 28413 times.
✓ Branch 1 taken 3600 times.
32013 if(s_version < 4)
5432 {
5433 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5434 3600 }
5435 32013 }
5436
5437
2/2
✓ Branch 0 taken 10287 times.
✓ Branch 1 taken 384 times.
10671 if(Header->zelda_version < 0x193)
5438 {
5439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5440 {
5441 return qe_invalid;
5442 }
5443 384 }
5444
5445
2/2
✓ Branch 0 taken 32013 times.
✓ Branch 1 taken 10671 times.
42684 for(int32_t j=0; j<3; j++)
5446 {
5447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32013 times.
32013 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5448 {
5449 return qe_invalid;
5450 }
5451 32013 }
5452
5453
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9471 times.
10671 if(s_version > 3)
5454 {
5455
2/2
✓ Branch 0 taken 28413 times.
✓ Branch 1 taken 9471 times.
37884 for(int32_t j=0; j<3; j++)
5456 {
5457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28413 times.
28413 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5458 return qe_invalid;
5459 28413 }
5460 9471 }
5461
5462 /*
5463 if(s_version < 8)
5464 {
5465 for(int32_t j=0; j<3; j++)
5466 {
5467 (&temp_misc.shop[i].str[j])=0; //initialise.
5468 }
5469 }
5470 */
5471 10671 }
5472
5473 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5474
2/2
✓ Branch 0 taken 199424 times.
✓ Branch 1 taken 779 times.
200203 for(int32_t i=0; i<maxshops; ++i)
5475 {
5476
2/2
✓ Branch 0 taken 398848 times.
✓ Branch 1 taken 199424 times.
598272 for(int32_t j=0; j<3-1; j++)
5477 {
5478
2/2
✓ Branch 0 taken 598272 times.
✓ Branch 1 taken 398848 times.
997120 for(int32_t k=0; k<2-j; k++)
5479 {
5480
2/2
✓ Branch 0 taken 23150 times.
✓ Branch 1 taken 575122 times.
598272 if(temp_misc.shop[i].hasitem[k]==0)
5481 {
5482 575122 swaptmp = temp_misc.shop[i].item[k];
5483 575122 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5484 575122 temp_misc.shop[i].item[k+1] = swaptmp;
5485 575122 swaptmp = temp_misc.shop[i].price[k];
5486 575122 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5487 575122 temp_misc.shop[i].price[k+1] = swaptmp;
5488 575122 swaptmp = temp_misc.shop[i].hasitem[k];
5489 575122 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5490 575122 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5491 575122 }
5492 598272 }
5493 398848 }
5494 199424 }
5495
5496 //infos
5497
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 755 times.
779 if(Header->zelda_version > 0x192)
5498 {
5499
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(!p_igetw(&infos,f))
5500 {
5501 return qe_invalid;
5502 }
5503 755 }
5504
5505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779 times.
779 if (infos > NUM_INFOS)
5506 {
5507 return qe_invalid;
5508 }
5509
5510
5511
2/2
✓ Branch 0 taken 9989 times.
✓ Branch 1 taken 779 times.
10768 for(int32_t i=0; i<infos; i++)
5512 {
5513
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 9228 times.
9989 if(s_version > 6)
5514 {
5515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9228 times.
9228 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5516 {
5517 return qe_invalid;
5518 }
5519 9228 }
5520
5521
2/2
✓ Branch 0 taken 29967 times.
✓ Branch 1 taken 9989 times.
39956 for(int32_t j=0; j<3; j++)
5522 {
5523
3/4
✓ Branch 0 taken 29103 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
30255 if((Header->zelda_version < 0x192)||
5524
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 28815 times.
29103 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5525 {
5526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5527 {
5528 return qe_invalid;
5529 }
5530
5531 864 temp_misc.info[i].str[j]=tempbyte;
5532 864 }
5533 else
5534 {
5535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29103 times.
29103 if(!p_igetw(&temp_misc.info[i].str[j],f))
5536 {
5537 return qe_invalid;
5538 }
5539 }
5540 29967 }
5541
5542
2/2
✓ Branch 0 taken 9605 times.
✓ Branch 1 taken 384 times.
9989 if(Header->zelda_version < 0x193)
5543 {
5544
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5545 {
5546 return qe_invalid;
5547 }
5548 384 }
5549
5550
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 9893 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
9989 if((Header->zelda_version == 0x192)&&(Header->build>145))
5551 {
5552
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5553 {
5554 return qe_invalid;
5555 }
5556 96 }
5557
5558
2/2
✓ Branch 0 taken 29967 times.
✓ Branch 1 taken 9989 times.
39956 for(int32_t j=0; j<3; j++)
5559 {
5560
1/2
✓ Branch 0 taken 29967 times.
✗ Branch 1 not taken.
29967 if(!p_igetw(&temp_misc.info[i].price[j],f))
5561 {
5562 return qe_invalid;
5563 }
5564 29967 }
5565 9989 }
5566
5567 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5568
2/2
✓ Branch 0 taken 199424 times.
✓ Branch 1 taken 779 times.
200203 for(int32_t i=0; i<maxinfos; ++i)
5569 {
5570
2/2
✓ Branch 0 taken 398848 times.
✓ Branch 1 taken 199424 times.
598272 for(int32_t j=0; j<3-1; j++)
5571 {
5572
2/2
✓ Branch 0 taken 598272 times.
✓ Branch 1 taken 398848 times.
997120 for(int32_t k=0; k<2-j; k++)
5573 {
5574
2/2
✓ Branch 0 taken 11311 times.
✓ Branch 1 taken 586961 times.
598272 if(temp_misc.info[i].str[k]==0)
5575 {
5576 586961 swaptmp = temp_misc.info[i].str[k];
5577 586961 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5578 586961 temp_misc.info[i].str[k+1] = swaptmp;
5579 586961 swaptmp = temp_misc.info[i].price[k];
5580 586961 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5581 586961 temp_misc.info[i].price[k+1] = swaptmp;
5582 586961 }
5583 598272 }
5584 398848 }
5585 199424 }
5586
5587
5588 //warp rings
5589
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 696 times.
779 if(s_version > 5)
5590 696 warprings++;
5591
5592
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 755 times.
779 if(Header->zelda_version > 0x192)
5593 {
5594
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(!p_igetw(&warprings,f))
5595 {
5596 return qe_invalid;
5597 }
5598
5599
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 427 times.
755 if (warprings > NUM_WARP_RINGS)
5600 {
5601 // return qe_invalid;
5602 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5603 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5604 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5605 427 }
5606 755 }
5607
5608
2/2
✓ Branch 0 taken 8148 times.
✓ Branch 1 taken 779 times.
8927 for(int32_t i=0; i<warprings; i++)
5609 {
5610 // See above comment on the `warprings` range check.
5611 8148 bool keepdata = i < NUM_WARP_RINGS;
5612
5613
2/2
✓ Branch 0 taken 72212 times.
✓ Branch 1 taken 8148 times.
80360 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5614 {
5615
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 63252 times.
72212 if(s_version <= 3)
5616 {
5617
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&tempbyte,f))
5618 {
5619 return qe_invalid;
5620 }
5621
5622
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5623 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5624 8960 }
5625 else
5626 {
5627 word tempword;
5628
1/2
✓ Branch 0 taken 63252 times.
✗ Branch 1 not taken.
63252 if(!p_igetw(&tempword,f))
5629 {
5630 return qe_invalid;
5631 }
5632
5633
2/2
✓ Branch 0 taken 7182 times.
✓ Branch 1 taken 56070 times.
63252 if (keepdata)
5634 56070 temp_misc.warp[i].dmap[j] = tempword;
5635 }
5636 72212 }
5637
5638
2/2
✓ Branch 0 taken 72212 times.
✓ Branch 1 taken 8148 times.
80360 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5639 {
5640
1/2
✓ Branch 0 taken 72212 times.
✗ Branch 1 not taken.
72212 if(!p_getc(&tempbyte,f))
5641 {
5642 return qe_invalid;
5643 }
5644
2/2
✓ Branch 0 taken 10374 times.
✓ Branch 1 taken 61838 times.
72212 if (keepdata)
5645 61838 temp_misc.warp[i].scr[j] = tempbyte;
5646 72212 }
5647
5648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8148 times.
8148 if(!p_getc(&tempbyte,f))
5649 {
5650 return qe_invalid;
5651 }
5652
2/2
✓ Branch 0 taken 1197 times.
✓ Branch 1 taken 6951 times.
8148 if (keepdata)
5653 6951 temp_misc.warp[i].size = tempbyte;
5654
5655
2/2
✓ Branch 0 taken 7956 times.
✓ Branch 1 taken 192 times.
8148 if(Header->zelda_version < 0x193)
5656 {
5657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5658 {
5659 return qe_invalid;
5660 }
5661 192 }
5662 8148 }
5663
5664 //palette cycles
5665
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 24 times.
779 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5666 {
5667
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5668 {
5669
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5670 {
5671 18432 temp_misc.cycles[i][j].first=0;
5672 18432 temp_misc.cycles[i][j].count=0;
5673 18432 temp_misc.cycles[i][j].speed=0;
5674 18432 }
5675 6144 }
5676
5677
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5678
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5679 {
5680 18 palcycles=16;
5681 18 }
5682
5683
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5684 {
5685
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5686 {
5687
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5688 {
5689 return qe_invalid;
5690 }
5691
5692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5693 {
5694 return qe_invalid;
5695 }
5696
5697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5698 {
5699 return qe_invalid;
5700 }
5701 5472 }
5702 1824 }
5703 24 }
5704
5705 //Wind warps are now just another warp ring.
5706
2/2
✓ Branch 0 taken 696 times.
✓ Branch 1 taken 83 times.
779 if(s_version <= 5)
5707 {
5708
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 59 times.
83 if(Header->zelda_version > 0x192)
5709 {
5710
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&windwarps,f))
5711 {
5712 return qe_invalid;
5713 }
5714 59 }
5715
5716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5717 {
5718 return qe_invalid;
5719 }
5720
5721
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 83 times.
748 for(int32_t i=0; i<windwarps; i++)
5722 {
5723
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5724 {
5725
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&tempbyte,f))
5726 {
5727 return qe_invalid;
5728 }
5729
5730 665 temp_misc.warp[8].dmap[i]=tempbyte;
5731 665 }
5732 else
5733 {
5734 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5735 {
5736 return qe_invalid;
5737 }
5738 }
5739
5740
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5741 {
5742 return qe_invalid;
5743 }
5744
5745 665 temp_misc.warp[8].size = 9;
5746
5747
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version == 5)
5748 {
5749 if(!p_getc(&tempbyte,f))
5750 {
5751 return qe_invalid;
5752 }
5753 }
5754 665 }
5755 83 }
5756
5757
5758 //triforce pieces
5759
2/2
✓ Branch 0 taken 6232 times.
✓ Branch 1 taken 779 times.
7011 for(int32_t i=0; i<triforces; i++)
5760 {
5761
1/2
✓ Branch 0 taken 6232 times.
✗ Branch 1 not taken.
6232 if(!p_getc(&temp_misc.triforce[i],f))
5762 {
5763 return qe_invalid;
5764 }
5765 6232 }
5766
5767 //misc color data
5768
2/2
✓ Branch 0 taken 696 times.
✓ Branch 1 taken 83 times.
779 if(s_version<3)
5769 {
5770
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5771 {
5772 return qe_invalid;
5773 }
5774
5775
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5776 {
5777 return qe_invalid;
5778 }
5779
5780
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5781 {
5782 return qe_invalid;
5783 }
5784
5785
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5786 {
5787 return qe_invalid;
5788 }
5789
5790
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5791 {
5792 return qe_invalid;
5793 }
5794
5795
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5796 {
5797 return qe_invalid;
5798 }
5799
5800
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5801 {
5802 return qe_invalid;
5803 }
5804
5805
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5806 {
5807 return qe_invalid;
5808 }
5809
5810
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5811 {
5812 return qe_invalid;
5813 }
5814
5815
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5816 {
5817 return qe_invalid;
5818 }
5819
5820
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5821 {
5822 return qe_invalid;
5823 }
5824
5825
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5826 {
5827 return qe_invalid;
5828 }
5829
5830
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5831 {
5832 return qe_invalid;
5833 }
5834
5835
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5836 {
5837 return qe_invalid;
5838 }
5839
5840
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5841 {
5842 return qe_invalid;
5843 }
5844
5845
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5846 {
5847 return qe_invalid;
5848 }
5849
5850
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5851 {
5852 return qe_invalid;
5853 }
5854
5855
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5856 {
5857 return qe_invalid;
5858 }
5859
5860
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5861 {
5862 return qe_invalid;
5863 }
5864
5865
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5866 {
5867 return qe_invalid;
5868 }
5869
5870
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5871 {
5872 return qe_invalid;
5873 }
5874
5875
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5876 {
5877 return qe_invalid;
5878 }
5879
5880
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5881 {
5882 return qe_invalid;
5883 }
5884
5885
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5886 {
5887 return qe_invalid;
5888 }
5889
5890
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
5891 {
5892 return qe_invalid;
5893 }
5894
5895
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
5896 {
5897 return qe_invalid;
5898 }
5899
5900
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5901 {
5902 return qe_invalid;
5903 }
5904
5905 83 temp_misc.colors.msgtext = 0x01;
5906
5907
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
5908 {
5909
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
5910 {
5911
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
5912 {
5913 return qe_invalid;
5914 }
5915 168 }
5916 24 }
5917
5918
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
5919 {
5920
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
5921 {
5922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
5923 {
5924 return qe_invalid;
5925 }
5926 1536 }
5927 6 }
5928
5929
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(s_version>1)
5930 {
5931 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5932 {
5933 return qe_invalid;
5934 }
5935 }
5936
5937 //save game icons
5938
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
5939
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5940 {
5941 18 icons=3;
5942 18 }
5943
5944
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
5945 {
5946
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
5947 {
5948 return qe_invalid;
5949 }
5950 314 }
5951 83 }
5952
5953
3/4
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
785 if((Header->zelda_version < 0x192)||
5954
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 755 times.
761 ((Header->zelda_version == 0x192)&&(Header->build<30)))
5955 {
5956 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5957
5958 18 return 0;
5959 }
5960
5961 //pond information
5962
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 6 times.
761 if(Header->zelda_version < 0x193)
5963 {
5964
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
5965 {
5966 pondsize=25;
5967 }
5968
5969
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
5970 {
5971
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
5972 {
5973
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
5974 {
5975 return qe_invalid;
5976
5977 }
5978 6912 }
5979 96 }
5980 6 }
5981
5982 //end string
5983
2/4
✓ Branch 0 taken 761 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
767 if((Header->zelda_version < 0x192)||
5984
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 755 times.
761 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5985 {
5986 if(!p_getc(&tempbyte,f))
5987 {
5988 return qe_invalid;
5989 }
5990
5991 temp_misc.endstring=tempbyte;
5992
5993 if(!p_getc(&tempbyte,f))
5994 {
5995 return qe_invalid;
5996 }
5997 }
5998 else
5999 {
6000
1/2
✓ Branch 0 taken 761 times.
✗ Branch 1 not taken.
761 if(!p_igetw(&temp_misc.endstring,f))
6001 {
6002 return qe_invalid;
6003 }
6004 }
6005
6006 //expansion
6007
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 6 times.
761 if(Header->zelda_version < 0x193)
6008 {
6009
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
6010 {
6011 expansionsize=99*2;
6012 }
6013
6014
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
6015 {
6016
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
6017 {
6018 return qe_invalid;
6019 }
6020 1176 }
6021 6 }
6022 //shops v8
6023
6024
6025
2/2
✓ Branch 0 taken 581 times.
✓ Branch 1 taken 180 times.
761 if(s_version >= 8)
6026 {
6027
2/2
✓ Branch 0 taken 2128 times.
✓ Branch 1 taken 180 times.
2308 for(int32_t i=0; i<shops; i++)
6028 {
6029
2/2
✓ Branch 0 taken 6384 times.
✓ Branch 1 taken 2128 times.
8512 for(int32_t j=0; j<3; j++)
6030 {
6031
1/2
✓ Branch 0 taken 6384 times.
✗ Branch 1 not taken.
6384 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6032 return qe_invalid;
6033 6384 }
6034 2128 }
6035 180 }
6036
6037 761 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6038 761 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6039
6040 //v9 includes quest misc[32]
6041 // ... this has been deprecated (2024)
6042
2/2
✓ Branch 0 taken 581 times.
✓ Branch 1 taken 180 times.
761 if(s_version >= 9)
6043 {
6044
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 180 times.
5940 for ( int32_t q = 0; q < 32; q++ )
6045 {
6046
1/2
✓ Branch 0 taken 5760 times.
✗ Branch 1 not taken.
5760 if(!p_igetl(&temp_misc.questmisc[q],f))
6047 return qe_invalid;
6048 5760 }
6049 // this was string labels
6050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if (pack_fseek(f, 32 * 128))
6051 return qe_invalid;
6052 180 }
6053
6054
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 581 times.
761 if(s_version >= 11 )
6055 {
6056
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6057 return qe_invalid;
6058 180 }
6059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 581 times.
581 else if(s_version < 11 )
6060 {
6061 581 temp_misc.zscript_last_compiled_version = -1;
6062 581 }
6063
6064 761 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6065
6066
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 581 times.
761 if(s_version >= 12)
6067 {
6068 byte spr;
6069
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 180 times.
46260 for(int32_t q = 0; q < sprMAX; ++q)
6070 {
6071
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_getc(&spr,f))
6072 return qe_invalid;
6073 46080 temp_misc.sprites[q] = spr;
6074 46080 }
6075 180 }
6076 else
6077 {
6078 581 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6079 //temp_misc.sprites[sprFALL] = ;
6080 }
6081
6082
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 581 times.
761 if(s_version >= 13)
6083 {
6084
2/2
✓ Branch 0 taken 11520 times.
✓ Branch 1 taken 180 times.
11700 for(size_t q = 0; q < 64; ++q)
6085 {
6086 11520 bottletype* bt = &(temp_misc.bottle_types[q]);
6087
1/2
✓ Branch 0 taken 11520 times.
✗ Branch 1 not taken.
11520 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6088 return qe_invalid;
6089
2/2
✓ Branch 0 taken 34560 times.
✓ Branch 1 taken 11520 times.
46080 for(size_t j = 0; j < 3; ++j)
6090 {
6091
1/2
✓ Branch 0 taken 34560 times.
✗ Branch 1 not taken.
34560 if (!p_getc(&(bt->counter[j]), f))
6092 return qe_invalid;
6093
1/2
✓ Branch 0 taken 34560 times.
✗ Branch 1 not taken.
34560 if (!p_igetw(&(bt->amount[j]), f))
6094 return qe_invalid;
6095 34560 }
6096
1/2
✓ Branch 0 taken 11520 times.
✗ Branch 1 not taken.
11520 if (!p_getc(&(bt->flags), f))
6097 return qe_invalid;
6098
1/2
✓ Branch 0 taken 11520 times.
✗ Branch 1 not taken.
11520 if (!p_getc(&(bt->next_type), f))
6099 return qe_invalid;
6100 11520 }
6101
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 180 times.
46260 for(size_t q = 0; q < 256; ++q)
6102 {
6103 46080 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6104
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6105 return qe_invalid;
6106
2/2
✓ Branch 0 taken 138240 times.
✓ Branch 1 taken 46080 times.
184320 for(size_t j = 0; j < 3; ++j)
6107 {
6108
1/2
✓ Branch 0 taken 138240 times.
✗ Branch 1 not taken.
138240 if (!p_getc(&(bst->fill[j]), f))
6109 return qe_invalid;
6110
1/2
✓ Branch 0 taken 138240 times.
✗ Branch 1 not taken.
138240 if (!p_igetw(&(bst->comb[j]), f))
6111 return qe_invalid;
6112
1/2
✓ Branch 0 taken 138240 times.
✗ Branch 1 not taken.
138240 if (!p_getc(&(bst->cset[j]), f))
6113 return qe_invalid;
6114
1/2
✓ Branch 0 taken 138240 times.
✗ Branch 1 not taken.
138240 if (!p_igetw(&(bst->price[j]), f))
6115 return qe_invalid;
6116
1/2
✓ Branch 0 taken 138240 times.
✗ Branch 1 not taken.
138240 if (!p_igetw(&(bst->str[j]), f))
6117 return qe_invalid;
6118 138240 }
6119 46080 }
6120 180 }
6121 else
6122 {
6123
2/2
✓ Branch 0 taken 37184 times.
✓ Branch 1 taken 581 times.
37765 for(size_t q = 0; q < 64; ++q)
6124 37184 temp_misc.bottle_types[q].clear();
6125
2/2
✓ Branch 0 taken 148736 times.
✓ Branch 1 taken 581 times.
149317 for(size_t q = 0; q < 256; ++q)
6126 148736 temp_misc.bottle_shop_types[q].clear();
6127 }
6128
6129
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 581 times.
761 if(s_version >= 14)
6130 {
6131 byte msfx;
6132
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 180 times.
46260 for(int32_t q = 0; q < sfxMAX; ++q)
6133 {
6134
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_getc(&msfx,f))
6135 return qe_invalid;
6136 46080 temp_misc.miscsfx[q] = msfx;
6137 46080 }
6138 180 }
6139 else
6140 {
6141 581 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6142 581 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6143 581 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6144 }
6145
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 581 times.
761 if(s_version < 15)
6146 {
6147 581 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6148 581 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6149 581 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6150 581 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6151 581 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6152 581 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6153 581 }
6154
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 598 times.
761 if(s_version < 16)
6155 {
6156 598 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6157 598 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6158 598 }
6159
6160
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 760 times.
761 if (!should_skip)
6161 760 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6162
6163 761 return 0;
6164 779 }
6165
6166 extern char *item_string[MAXITEMS];
6167 extern const char *old_item_string[iLast];
6168 extern char *weapon_string[MAXWPNS];
6169 extern const char *old_weapon_string[wLast];
6170
6171 467 int32_t readitems(PACKFILE *f, word version, word build)
6172 {
6173
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 24 times.
467 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6174
6175 byte padding;
6176 int32_t dummy;
6177 467 word items_to_read=MAXITEMS;
6178 itemdata tempitem;
6179 467 word s_version=0;
6180 word dummy_word;
6181
6182
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 6 times.
467 if(version < 0x186)
6183 {
6184 6 items_to_read=64;
6185 6 }
6186
6187
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 443 times.
467 if(version > 0x192)
6188 {
6189 443 items_to_read=0;
6190
6191 //section version info
6192
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&s_version,f))
6193 {
6194 return qe_invalid;
6195 }
6196
6197 443 FFCore.quest_format[vItems] = s_version;
6198
6199
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!read_deprecated_section_cversion(f))
6200 {
6201 return qe_invalid;
6202 }
6203
6204 //section size
6205
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetl(&dummy,f))
6206 {
6207 return qe_invalid;
6208 }
6209
6210 //finally... section data
6211
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&items_to_read,f))
6212 {
6213 return qe_invalid;
6214 }
6215
6216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if (items_to_read > MAXITEMS)
6217 {
6218 return qe_invalid;
6219 }
6220 443 }
6221
6222
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 83 times.
467 if(s_version>1)
6223 {
6224
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 384 times.
98688 for(int32_t i=0; i<items_to_read; i++)
6225 {
6226 char tempname[64];
6227
6228
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!pfread(tempname, 64, f))
6229 {
6230 return qe_invalid;
6231 }
6232
6233 98304 item_string[i][0] = '\0';
6234 98304 strncat(item_string[i], tempname, 64 - 1);
6235 98304 }
6236 384 }
6237
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6238 {
6239
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6240 {
6241 20992 reset_itemname(i);
6242 20992 }
6243 82 }
6244
6245
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 466 times.
467 if (!should_skip)
6246
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<MAXITEMS; i++)
6247 {
6248 119296 itemdata& id = itemsbuf[i];
6249 119296 memset(&id, 0, sizeof(itemdata));
6250 119296 id.count=-1;
6251 119296 id.playsound=WAV_SCALE;
6252 119296 reset_itembuf(&id,i);
6253 119762 }
6254
6255
2/2
✓ Branch 0 taken 107426 times.
✓ Branch 1 taken 467 times.
107893 for(int32_t i=0; i<items_to_read; i++)
6256 {
6257 107426 memset(&tempitem, 0, sizeof(itemdata));
6258 107426 reset_itembuf(&tempitem,i);
6259
6260
6261
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 61346 times.
107426 if ( s_version > 35 ) //expanded tiles
6262 {
6263
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.tile,f))
6264 {
6265 return qe_invalid;
6266 }
6267 46080 }
6268 else
6269 {
6270
1/2
✓ Branch 0 taken 61346 times.
✗ Branch 1 not taken.
61346 if(!p_igetw(&tempitem.tile,f))
6271 {
6272 return qe_invalid;
6273 }
6274 }
6275
6276
1/2
✓ Branch 0 taken 107426 times.
✗ Branch 1 not taken.
107426 if(!p_getc(&tempitem.misc_flags,f))
6277 {
6278 return qe_invalid;
6279 }
6280
6281
1/2
✓ Branch 0 taken 107426 times.
✗ Branch 1 not taken.
107426 if(!p_getc(&tempitem.csets,f))
6282 {
6283 return qe_invalid;
6284 }
6285
6286
1/2
✓ Branch 0 taken 107426 times.
✗ Branch 1 not taken.
107426 if(!p_getc(&tempitem.frames,f))
6287 {
6288 return qe_invalid;
6289 }
6290
6291
1/2
✓ Branch 0 taken 107426 times.
✗ Branch 1 not taken.
107426 if(!p_getc(&tempitem.speed,f))
6292 {
6293 return qe_invalid;
6294 }
6295
6296
1/2
✓ Branch 0 taken 107426 times.
✗ Branch 1 not taken.
107426 if(!p_getc(&tempitem.delay,f))
6297 {
6298 return qe_invalid;
6299 }
6300
6301
2/2
✓ Branch 0 taken 102434 times.
✓ Branch 1 taken 4992 times.
107426 if(version < 0x193)
6302 {
6303
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6304 {
6305 return qe_invalid;
6306 }
6307
6308
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6309 {
6310
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6311 256 continue;
6312
6313
3/3
✓ Branch 0 taken 4690 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6314 {
6315 case iShield:
6316 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6317 23 break;
6318
6319 case iMShield:
6320 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6321 23 break;
6322
6323 default:
6324 4690 tempitem.ltm=0;
6325 4690 break;
6326 }
6327
6328 4736 tempitem.count=-1;
6329 4736 tempitem.flags=item_none;
6330 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6331 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6332 4736 tempitem.family=0xFF;
6333 4736 tempitem.playsound=WAV_SCALE;
6334 4736 reset_itembuf(&tempitem,i);
6335
6336 4736 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6337
6338 4736 continue;
6339 }
6340 }
6341
6342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102434 times.
102434 if(!p_igetl(&tempitem.ltm,f))
6343 {
6344 return qe_invalid;
6345 }
6346
6347
1/2
✓ Branch 0 taken 102434 times.
✗ Branch 1 not taken.
102434 if(version < 0x193)
6348 {
6349 for(int32_t q=0; q<12; q++)
6350 {
6351 if(!p_getc(&padding,f))
6352 {
6353 return qe_invalid;
6354 }
6355 }
6356 }
6357
6358
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 4130 times.
102434 if(s_version>1)
6359 {
6360
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 52224 times.
98304 if ( s_version >= 31 )
6361 {
6362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_igetl(&tempitem.family,f))
6363 {
6364 return qe_invalid;
6365 }
6366 46080 }
6367 else
6368 {
6369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52224 times.
52224 if(!p_getc(&tempitem.family,f))
6370 {
6371 return qe_invalid;
6372 }
6373 }
6374
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(s_version < 16)
6375 if(tempitem.family == 0xFF)
6376 tempitem.family = itype_misc;
6377
6378
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.fam_type,f))
6379 {
6380 return qe_invalid;
6381 }
6382
6383
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(s_version>5)
6384 {
6385
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 52224 times.
98304 if(s_version>=31)
6386 {
6387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_igetl(&tempitem.power,f))
6388 {
6389 return qe_invalid;
6390 }
6391 46080 }
6392 else
6393 {
6394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52224 times.
52224 if(!p_getc(&tempitem.power,f))
6395 {
6396 return qe_invalid;
6397 }
6398 }
6399
6400 //converted flags from 16b to 32b -Z
6401
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 46080 times.
98304 if ( s_version < 41 )
6402 {
6403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52224 times.
52224 if(!p_igetw(&tempitem.flags,f))
6404 {
6405 return qe_invalid;
6406 }
6407 52224 }
6408 else
6409 {
6410
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.flags,f))
6411 {
6412 return qe_invalid;
6413 }
6414 }
6415 98304 }
6416 else
6417 {
6418 //tempitem.power = tempitem.fam_type;
6419 char tempchar;
6420
6421 if(!p_getc(&tempchar,f))
6422 {
6423 return qe_invalid;
6424 }
6425
6426 if (tempchar) tempitem.flags |= item_gamedata;
6427 }
6428
6429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetw(&tempitem.script,f))
6430 {
6431 return qe_invalid;
6432 }
6433
6434
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(s_version<=3)
6435 {
6436 if(tempitem.script > NUMSCRIPTITEM)
6437 {
6438 tempitem.script = 0;
6439 }
6440 }
6441
6442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_getc(&tempitem.count,f))
6443 {
6444 return qe_invalid;
6445 }
6446
6447
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetw(&tempitem.amount,f))
6448 {
6449 return qe_invalid;
6450 }
6451
6452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetw(&tempitem.collect_script,f))
6453 {
6454 return qe_invalid;
6455 }
6456
6457
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(s_version<=3)
6458 {
6459 if(tempitem.collect_script > NUMSCRIPTITEM)
6460 {
6461 tempitem.collect_script = 0;
6462 }
6463 }
6464
6465
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetw(&tempitem.setmax,f))
6466 {
6467 return qe_invalid;
6468 }
6469
6470
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetw(&tempitem.max,f))
6471 {
6472 return qe_invalid;
6473 }
6474
6475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_getc(&tempitem.playsound,f))
6476 {
6477 return qe_invalid;
6478 }
6479
6480
2/2
✓ Branch 0 taken 786432 times.
✓ Branch 1 taken 98304 times.
884736 for(int32_t j=0; j<8; j++)
6481 {
6482
1/2
✓ Branch 0 taken 786432 times.
✗ Branch 1 not taken.
786432 if(!p_igetl(&tempitem.initiald[j],f))
6483 {
6484 return qe_invalid;
6485 }
6486 786432 }
6487
6488
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 98304 times.
294912 for(int32_t j=0; j<2; j++)
6489 {
6490 byte temp;
6491
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&temp,f))
6492 {
6493 return qe_invalid;
6494 }
6495 196608 }
6496
6497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(s_version>4)
6498 {
6499
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(s_version>5)
6500 {
6501
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn,f))
6502 {
6503 return qe_invalid;
6504 }
6505
6506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_getc(&tempitem.wpn2,f))
6507 {
6508 return qe_invalid;
6509 }
6510
6511
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn3,f))
6512 {
6513 return qe_invalid;
6514 }
6515
6516
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn4,f))
6517 {
6518 return qe_invalid;
6519 }
6520
6521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(s_version>=15)
6522 {
6523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_getc(&tempitem.wpn5,f))
6524 {
6525 return qe_invalid;
6526 }
6527
6528
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn6,f))
6529 {
6530 return qe_invalid;
6531 }
6532
6533
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn7,f))
6534 {
6535 return qe_invalid;
6536 }
6537
6538
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn8,f))
6539 {
6540 return qe_invalid;
6541 }
6542
6543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_getc(&tempitem.wpn9,f))
6544 {
6545 return qe_invalid;
6546 }
6547
6548
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.wpn10,f))
6549 {
6550 return qe_invalid;
6551 }
6552 98304 }
6553
6554
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_getc(&tempitem.pickup_hearts,f))
6555 {
6556 return qe_invalid;
6557 }
6558
6559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(s_version<15)
6560 {
6561 if(!p_igetw(&dummy_word,f))
6562 {
6563 return qe_invalid;
6564 }
6565
6566 tempitem.misc1=dummy_word;
6567
6568 if(!p_igetw(&dummy_word,f))
6569 {
6570 return qe_invalid;
6571 }
6572
6573 tempitem.misc2=dummy_word;
6574 }
6575 else
6576 {
6577
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempitem.misc1,f))
6578 {
6579 return qe_invalid;
6580 }
6581
6582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetl(&tempitem.misc2,f))
6583 {
6584 return qe_invalid;
6585 }
6586
6587 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6588
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(s_version<24)
6589 {
6590 if(tempitem.family==itype_shield)
6591 {
6592 tempitem.misc1|=sh_script;
6593 }
6594 }
6595 }
6596
6597
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 46080 times.
98304 if(s_version < 53)
6598 {
6599 byte tempbyte;
6600
1/2
✓ Branch 0 taken 52224 times.
✗ Branch 1 not taken.
52224 if(!p_getc(&tempbyte,f))
6601 {
6602 return qe_invalid;
6603 }
6604 52224 tempitem.cost_amount[0] = tempbyte;
6605 52224 }
6606 else
6607 {
6608
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 46080 times.
138240 for(auto q = 0; q < 2; ++q)
6609 {
6610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92160 times.
92160 if(!p_igetw(&tempitem.cost_amount[q],f))
6611 {
6612 return qe_invalid;
6613 }
6614 92160 }
6615 }
6616 98304 }
6617 else
6618 {
6619 char tempchar;
6620
6621 if(!p_getc(&tempchar,f))
6622 {
6623 return qe_invalid;
6624 }
6625
6626 if (tempchar) tempitem.flags |= item_edible;
6627 }
6628
6629 // June 2007: more misc. attributes
6630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(s_version>=12)
6631 {
6632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(s_version<15)
6633 {
6634 if(!p_igetw(&dummy_word,f))
6635 {
6636 return qe_invalid;
6637 }
6638
6639 tempitem.misc3=dummy_word;
6640
6641 if(!p_igetw(&dummy_word,f))
6642 {
6643 return qe_invalid;
6644 }
6645
6646 tempitem.misc4=dummy_word;
6647 }
6648 else
6649 {
6650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetl(&tempitem.misc3,f))
6651 {
6652 return qe_invalid;
6653 }
6654
6655
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempitem.misc4,f))
6656 {
6657 return qe_invalid;
6658 }
6659
6660
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempitem.misc5,f))
6661 {
6662 return qe_invalid;
6663 }
6664
6665
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempitem.misc6,f))
6666 {
6667 return qe_invalid;
6668 }
6669
6670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetl(&tempitem.misc7,f))
6671 {
6672 return qe_invalid;
6673 }
6674
6675
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempitem.misc8,f))
6676 {
6677 return qe_invalid;
6678 }
6679
6680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_igetl(&tempitem.misc9,f))
6681 {
6682 return qe_invalid;
6683 }
6684
6685
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!p_igetl(&tempitem.misc10,f))
6686 {
6687 return qe_invalid;
6688 }
6689 }
6690
6691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98304 times.
98304 if(!p_getc(&tempitem.usesound,f))
6692 {
6693 return qe_invalid;
6694 }
6695
6696
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 52224 times.
98304 if(s_version >= 49)
6697 {
6698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_getc(&tempitem.usesound2,f))
6699 {
6700 return qe_invalid;
6701 }
6702 46080 }
6703 52224 else tempitem.usesound2 = 0;
6704
6705
3/4
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 46080 times.
✓ Branch 2 taken 52224 times.
✗ Branch 3 not taken.
98304 if(s_version < 50 && tempitem.family == itype_mirror)
6706 {
6707 //Split continue/dmap warp effect/sfx, port for old
6708 tempitem.misc2 = tempitem.misc1;
6709 tempitem.usesound2 = tempitem.usesound;
6710 }
6711 98304 }
6712 98304 }
6713
6714
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 46080 times.
98304 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6715 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_getc(&tempitem.useweapon,f))
6717 {
6718 return qe_invalid;
6719 }
6720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_getc(&tempitem.usedefence,f))
6721 {
6722 return qe_invalid;
6723 }
6724
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.weaprange,f))
6725 {
6726 return qe_invalid;
6727 }
6728
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.weapduration,f))
6729 {
6730 return qe_invalid;
6731 }
6732
2/2
✓ Branch 0 taken 460800 times.
✓ Branch 1 taken 46080 times.
506880 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6733 {
6734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460800 times.
460800 if(!p_igetl(&tempitem.weap_pattern[q],f))
6735 {
6736 return qe_invalid;
6737 }
6738 460800 }
6739 46080 }
6740
6741
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 46080 times.
98304 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6742 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6743
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.duplicates,f))
6744 {
6745 return qe_invalid;
6746 }
6747
2/2
✓ Branch 0 taken 368640 times.
✓ Branch 1 taken 46080 times.
414720 for ( int32_t q = 0; q < INITIAL_D; q++ )
6748 {
6749
1/2
✓ Branch 0 taken 368640 times.
✗ Branch 1 not taken.
368640 if(!p_igetl(&tempitem.weap_initiald[q],f))
6750 {
6751 return qe_invalid;
6752 }
6753 368640 }
6754
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 46080 times.
138240 for ( int32_t q = 0; q < 2; q++ )
6755 {
6756 byte temp;
6757
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_getc(&temp,f))
6758 {
6759 return qe_invalid;
6760 }
6761 92160 }
6762
6763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_getc(&tempitem.drawlayer,f))
6764 {
6765 return qe_invalid;
6766 }
6767
6768
6769
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.hxofs,f))
6770 {
6771 return qe_invalid;
6772 }
6773
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.hyofs,f))
6774 {
6775 return qe_invalid;
6776 }
6777
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.hxsz,f))
6778 {
6779 return qe_invalid;
6780 }
6781
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.hysz,f))
6782 {
6783 return qe_invalid;
6784 }
6785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_igetl(&tempitem.hzsz,f))
6786 {
6787 return qe_invalid;
6788 }
6789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_igetl(&tempitem.xofs,f))
6790 {
6791 return qe_invalid;
6792 }
6793
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.yofs,f))
6794 {
6795 return qe_invalid;
6796 }
6797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_igetl(&tempitem.weap_hxofs,f))
6798 {
6799 return qe_invalid;
6800 }
6801
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.weap_hyofs,f))
6802 {
6803 return qe_invalid;
6804 }
6805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_igetl(&tempitem.weap_hxsz,f))
6806 {
6807 return qe_invalid;
6808 }
6809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_igetl(&tempitem.weap_hysz,f))
6810 {
6811 return qe_invalid;
6812 }
6813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_igetl(&tempitem.weap_hzsz,f))
6814 {
6815 return qe_invalid;
6816 }
6817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_igetl(&tempitem.weap_xofs,f))
6818 {
6819 return qe_invalid;
6820 }
6821
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.weap_yofs,f))
6822 {
6823 return qe_invalid;
6824 }
6825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_igetw(&tempitem.weaponscript,f))
6826 {
6827 return qe_invalid;
6828 }
6829
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.wpnsprite,f))
6830 {
6831 return qe_invalid;
6832 }
6833 46080 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6834
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 46080 times.
138240 for(auto q = 0; q < num_cost_tmr; ++q)
6835 {
6836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92160 times.
92160 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6837 {
6838 return qe_invalid;
6839 }
6840 92160 }
6841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 for(auto q = num_cost_tmr; q < 2; ++q)
6842 tempitem.magiccosttimer[q] = 0;
6843 46080 }
6844
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 46080 times.
98304 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6845 {
6846 //Item Size FLags, TileWidth, TileHeight
6847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_igetl(&tempitem.overrideFLAGS,f))
6848 {
6849 return qe_invalid;
6850 }
6851
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.tilew,f))
6852 {
6853 return qe_invalid;
6854 }
6855
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.tileh,f))
6856 {
6857 return qe_invalid;
6858 }
6859 46080 }
6860
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 46080 times.
98304 if ( s_version >= 29 ) //! More new vars.
6861 {
6862 //Item Size FLags, TileWidth, TileHeight
6863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
6864 {
6865 return qe_invalid;
6866 }
6867
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.weap_tilew,f))
6868 {
6869 return qe_invalid;
6870 }
6871
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.weap_tileh,f))
6872 {
6873 return qe_invalid;
6874 }
6875 46080 }
6876
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 46080 times.
98304 if ( s_version >= 30 ) //! More new vars.
6877 {
6878 //Pickup Type
6879
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempitem.pickup,f))
6880 {
6881 return qe_invalid;
6882 }
6883 46080 }
6884
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 46080 times.
98304 if ( s_version >= 32 ) //! More new vars.
6885 {
6886 //Pickup Type
6887
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetw(&tempitem.pstring,f))
6888 {
6889 return qe_invalid;
6890 }
6891 46080 }
6892
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 46080 times.
98304 if ( s_version >= 33 ) //! More new vars.
6893 {
6894 //Pickup Type
6895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(!p_igetw(&tempitem.pickup_string_flags,f))
6896 {
6897 return qe_invalid;
6898 }
6899 46080 }
6900
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 46080 times.
98304 if ( s_version >= 34 ) //! cost counter
6901 {
6902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46080 times.
46080 if(s_version < 53)
6903 {
6904 if(!p_getc(&tempitem.cost_counter[0],f))
6905 {
6906 return qe_invalid;
6907 }
6908 }
6909 else
6910 {
6911
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 46080 times.
138240 for(auto q = 0; q < 2; ++q)
6912 {
6913
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_getc(&tempitem.cost_counter[q],f))
6914 {
6915 return qe_invalid;
6916 }
6917 92160 }
6918 }
6919 46080 }
6920
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 46080 times.
98304 if ( s_version >= 44 ) //! sprite scripts
6921 {
6922
2/2
✓ Branch 0 taken 368640 times.
✓ Branch 1 taken 46080 times.
414720 for ( int32_t q = 0; q < 8; q++ )
6923 {
6924
2/2
✓ Branch 0 taken 23961600 times.
✓ Branch 1 taken 368640 times.
24330240 for ( int32_t w = 0; w < 65; w++ )
6925 {
6926
1/2
✓ Branch 0 taken 23961600 times.
✗ Branch 1 not taken.
23961600 if(!p_getc(&(tempitem.initD_label[q][w]),f))
6927 {
6928 return qe_invalid;
6929 }
6930 23961600 }
6931
2/2
✓ Branch 0 taken 23961600 times.
✓ Branch 1 taken 368640 times.
24330240 for ( int32_t w = 0; w < 65; w++ )
6932 {
6933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23961600 times.
23961600 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
6934 {
6935 return qe_invalid;
6936 }
6937 23961600 }
6938
2/2
✓ Branch 0 taken 23961600 times.
✓ Branch 1 taken 368640 times.
24330240 for ( int32_t w = 0; w < 65; w++ )
6939 {
6940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23961600 times.
23961600 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
6941 {
6942 return qe_invalid;
6943 }
6944 23961600 }
6945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368640 times.
368640 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
6946 {
6947 return qe_invalid;
6948 }
6949
6950 368640 }
6951
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 46080 times.
138240 for ( int32_t q = 0; q < 2; q++ )
6952 {
6953 byte temp;
6954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92160 times.
92160 if(!p_getc(&temp,f))
6955 {
6956 return qe_invalid;
6957 }
6958 92160 }
6959 //Pickup Type
6960
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetw(&tempitem.sprite_script,f))
6961 {
6962 return qe_invalid;
6963 }
6964 46080 }
6965
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 46080 times.
98304 if ( s_version >= 48 ) //! pickup flags
6966 {
6967
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_getc(&(tempitem.pickupflag),f))
6968 {
6969 return qe_invalid;
6970 }
6971 46080 }
6972
2/2
✓ Branch 0 taken 55552 times.
✓ Branch 1 taken 42752 times.
98304 if ( s_version >= 57 )
6973 {
6974 42752 std::string str;
6975
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42752 times.
✓ Branch 2 taken 42752 times.
✗ Branch 3 not taken.
42752 if(!p_getcstr(&str,f))
6976 return qe_invalid;
6977 42752 strncpy(tempitem.display_name,str.c_str(),255);
6978
1/3
✓ Branch 0 taken 42752 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
42752 }
6979 98304 }
6980 else
6981 {
6982 4130 tempitem.count=-1;
6983 4130 tempitem.family=itype_misc;
6984 4130 tempitem.flags=item_none;
6985 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6986 4130 tempitem.playsound=WAV_SCALE;
6987 4130 reset_itembuf(&tempitem,i);
6988 }
6989
6990
2/2
✓ Branch 0 taken 60706 times.
✓ Branch 1 taken 41728 times.
102434 if(s_version >= 58)
6991 {
6992
2/2
✓ Branch 0 taken 208640 times.
✓ Branch 1 taken 41728 times.
250368 for(int q = 0; q < WPNSPR_MAX; ++q)
6993 {
6994
1/2
✓ Branch 0 taken 208640 times.
✗ Branch 1 not taken.
208640 if(!p_getc(&tempitem.burnsprs[q],f))
6995 return qe_invalid;
6996
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 207360 times.
208640 if(s_version >= 59)
6997
1/2
✓ Branch 0 taken 207360 times.
✗ Branch 1 not taken.
207360 if(!p_getc(&tempitem.light_rads[q],f))
6998 return qe_invalid;
6999 208640 }
7000 41728 }
7001
7002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102434 times.
102434 if (!should_skip)
7003 {
7004
1/2
✓ Branch 0 taken 102434 times.
✗ Branch 1 not taken.
102434 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7005 {
7006 tempitem.script = 0;
7007 tempitem.weaponscript = 0;
7008 for(int q = 0; q < 8; ++q)
7009 {
7010 tempitem.initiald[q] = 0;
7011 tempitem.weap_initiald[q] = 0;
7012 }
7013 }
7014 102434 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7015 102434 }
7016 102434 }
7017
7018
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 466 times.
467 if (should_skip)
7019 1 return 0;
7020
7021 //////////////////////////////////////////////////////
7022 // Now do any updates because of new item additions
7023 // (These can't be done above because items_to_read
7024 // might be too low.)
7025 //////////////////////////////////////////////////////
7026
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<MAXITEMS; i++)
7027 {
7028 119296 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7029
7030 //Account for older quests that didn't have an actual item for the used letter
7031
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 98304 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
119296 if(s_version < 2 && i==iLetterUsed)
7032 {
7033 82 reset_itembuf(&tempitem, iLetterUsed);
7034 82 strcpy(item_string[i],old_item_string[i]);
7035 82 tempitem.tile = itemsbuf[iLetter].tile;
7036 82 tempitem.csets = itemsbuf[iLetter].csets;
7037 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7038 82 tempitem.frames = itemsbuf[iLetter].frames;
7039 82 tempitem.speed = itemsbuf[iLetter].speed;
7040 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7041 82 }
7042
7043
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 3)
7044 {
7045
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7046 {
7047 case iRocsFeather:
7048 case iHoverBoots:
7049 case iSpinScroll:
7050 case iL2SpinScroll:
7051 case iCrossScroll:
7052 case iQuakeScroll:
7053 case iL2QuakeScroll:
7054 case iWhispRing:
7055 case iL2WhispRing:
7056 case iChargeRing:
7057 case iL2ChargeRing:
7058 case iPerilScroll:
7059 case iWalletL3:
7060 case iQuiverL4:
7061 case iBombBagL4:
7062 case iBracelet:
7063 case iL2Bracelet:
7064 case iOldGlove:
7065 case iL2Ladder:
7066 case iWealthMedal:
7067 case iL2WealthMedal:
7068 case iL3WealthMedal:
7069 1804 reset_itembuf(&tempitem, i);
7070 1804 strcpy(item_string[i],old_item_string[i]);
7071 1804 break;
7072
7073 case iSShield:
7074 82 reset_itembuf(&tempitem, i);
7075 82 strcpy(item_string[i],old_item_string[i]);
7076 82 strcpy(item_string[iShield],old_item_string[iShield]);
7077 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7078 82 break;
7079 }
7080 20992 }
7081
7082
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 5)
7083 {
7084
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7085 {
7086 case iHeartRing:
7087 case iL2HeartRing:
7088 case iL3HeartRing:
7089 case iMagicRing:
7090 case iL2MagicRing:
7091 case iL3MagicRing:
7092 case iL4MagicRing:
7093 574 reset_itembuf(&tempitem, i);
7094 574 strcpy(item_string[i],old_item_string[i]);
7095 574 break;
7096 }
7097 20992 }
7098
7099
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7100 {
7101
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7102
2/2
✓ Branch 0 taken 19304 times.
✓ Branch 1 taken 1524 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7103
7104
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 328 times.
✓ Branch 8 taken 17302 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
✓ Branch 11 taken 82 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 82 times.
✓ Branch 34 taken 82 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7105 {
7106 case iTriforce:
7107 82 tempitem.fam_type=1;
7108 82 break;
7109
7110 case iBigTri:
7111 82 tempitem.fam_type=0;
7112 82 break;
7113
7114 case iBombs:
7115 82 tempitem.fam_type=i_bomb;
7116 82 tempitem.power=4;
7117 82 tempitem.wpn=wBOMB;
7118 82 tempitem.wpn2=wBOOM;
7119 82 tempitem.misc1 = 50;
7120
7121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7122
7123 82 break;
7124
7125 case iSBomb:
7126 82 tempitem.fam_type=i_sbomb;
7127 82 tempitem.power=16;
7128 82 tempitem.wpn=wSBOMB;
7129 82 tempitem.wpn2=wSBOOM;
7130 82 tempitem.misc1 = 50;
7131
7132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7133
7134 82 break;
7135
7136 case iBook:
7137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7138 tempitem.wpn = wFIREMAGIC;
7139
7140 82 break;
7141
7142 case iSArrow:
7143 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7144 82 tempitem.power=4;
7145 82 tempitem.flags|=item_gamedata;
7146 82 tempitem.wpn=wSARROW;
7147 82 break;
7148
7149 case iGArrow:
7150 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7151 82 tempitem.power=8;
7152 82 tempitem.flags|=(item_gamedata|item_flag1);
7153 82 tempitem.wpn=wGARROW;
7154 82 break;
7155
7156 case iBrang:
7157 82 tempitem.power=0;
7158 82 tempitem.wpn=wBRANG;
7159 82 tempitem.misc1=36;
7160 82 break;
7161
7162 case iMBrang:
7163 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7164 82 tempitem.power=0;
7165 82 tempitem.wpn=wMBRANG;
7166 82 break;
7167
7168 case iFBrang:
7169 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7170 82 tempitem.power=2;
7171 82 tempitem.wpn=wFBRANG;
7172 82 break;
7173
7174 case iBoots:
7175 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7176 82 tempitem.power=7;
7177 82 break;
7178
7179 case iWand:
7180 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7181 82 tempitem.power=2;
7182 82 tempitem.wpn=wWAND;
7183 82 tempitem.wpn3=wMAGIC;
7184 82 break;
7185
7186 case iBCandle:
7187 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7188 82 tempitem.power=1;
7189 82 tempitem.flags|=(item_gamedata|item_flag1);
7190 82 tempitem.wpn3=wFIRE;
7191 82 break;
7192
7193 case iRCandle:
7194 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7195 82 tempitem.power=1;
7196 82 tempitem.wpn3=wFIRE;
7197 82 break;
7198
7199 case iSword:
7200 82 tempitem.power=1;
7201 82 tempitem.flags|= item_flag4 |item_flag2;
7202 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7203 82 tempitem.wpn2=wSWORDSLASH;
7204 82 break;
7205
7206 case iWSword:
7207 82 tempitem.power=2;
7208 82 tempitem.flags|= item_flag4 |item_flag2;
7209 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7210 82 tempitem.wpn2=wWSWORDSLASH;
7211 82 break;
7212
7213 case iMSword:
7214 82 tempitem.power=4;
7215 82 tempitem.flags|= item_flag4 |item_flag2;
7216 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7217 82 tempitem.wpn2=wMSWORDSLASH;
7218 82 break;
7219
7220 case iXSword:
7221 82 tempitem.power=8;
7222 82 tempitem.flags|= item_flag4 |item_flag2;
7223 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7224 82 tempitem.wpn2=wXSWORDSLASH;
7225 82 break;
7226
7227 case iDivineProtection:
7228 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7229 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7230 82 tempitem.wpn=wDIVINEPROTECTION1A;
7231 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7232 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7233 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7234 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7235 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7236 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7237 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7238 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7239 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7240 82 tempitem.misc1=512;
7241 82 tempitem.cost_amount[0]=64;
7242 82 break;
7243
7244 case iLens:
7245 82 tempitem.misc1=60;
7246 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7247 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7248 82 break;
7249
7250 case iArrow:
7251 82 tempitem.power=2;
7252 82 tempitem.wpn=wARROW;
7253 82 break;
7254
7255 case iHoverBoots:
7256 82 tempitem.misc1=45;
7257 82 tempitem.wpn=iwHover;
7258 82 break;
7259
7260 case iDivineFire:
7261 82 tempitem.power=8;
7262 82 tempitem.wpn=wDIVINEFIRE1A;
7263 82 tempitem.wpn2=wDIVINEFIRE1B;
7264 82 tempitem.wpn3=wDIVINEFIRES1A;
7265 82 tempitem.wpn4=wDIVINEFIRES1B;
7266 82 tempitem.misc1 = 32;
7267 82 tempitem.misc2 = 200;
7268 82 tempitem.cost_amount[0]=32;
7269 82 break;
7270
7271 case iDivineEscape:
7272 82 tempitem.cost_amount[0]=32;
7273 82 break;
7274
7275 case iHookshot:
7276 82 tempitem.power=0;
7277 82 tempitem.flags&=~item_flag1;
7278 82 tempitem.wpn=wHSHEAD;
7279 82 tempitem.wpn2=wHSCHAIN_H;
7280 82 tempitem.wpn4=wHSHANDLE;
7281 82 tempitem.wpn3=wHSCHAIN_V;
7282 82 tempitem.misc1=50;
7283 82 tempitem.misc2=100;
7284 82 break;
7285
7286 case iLongshot:
7287 82 tempitem.power=0;
7288 82 tempitem.flags&=~item_flag1;
7289 82 tempitem.wpn=wLSHEAD;
7290 82 tempitem.wpn2=wLSCHAIN_H;
7291 82 tempitem.wpn4=wLSHANDLE;
7292 82 tempitem.wpn3=wLSCHAIN_V;
7293 82 tempitem.misc1=99;
7294 82 tempitem.misc2=100;
7295 82 break;
7296
7297 case iHammer:
7298 82 tempitem.power=4;
7299 82 tempitem.wpn=wHAMMER;
7300 82 tempitem.wpn2=iwHammerSmack;
7301 82 break;
7302
7303 case iCByrna:
7304 82 tempitem.power=1;
7305 82 tempitem.wpn=wCBYRNA;
7306 82 tempitem.wpn2=wCBYRNASLASH;
7307 82 tempitem.wpn3=wCBYRNAORB;
7308 82 tempitem.misc1=4;
7309 82 tempitem.misc2=16;
7310 82 tempitem.misc3=1;
7311 82 tempitem.cost_amount[0]=1;
7312 82 break;
7313
7314 case iWhistle:
7315 82 tempitem.wpn=wWIND;
7316 82 tempitem.misc1=3;
7317 82 tempitem.flags|=item_flag1;
7318 82 break;
7319
7320 case iBRing:
7321 82 tempitem.power=2;
7322 82 tempitem.misc1=spBLUE;
7323 82 break;
7324
7325 case iRRing:
7326 82 tempitem.power=4;
7327 82 tempitem.misc1=spRED;
7328 82 break;
7329
7330 case iGRing:
7331 82 tempitem.power=8;
7332 82 tempitem.misc1=spGOLD;
7333 82 break;
7334
7335 case iSpinScroll:
7336 82 tempitem.power = 2;
7337 82 tempitem.misc1 = 1;
7338 82 break;
7339
7340 case iL2SpinScroll:
7341 82 tempitem.family=itype_spinscroll2;
7342 82 tempitem.fam_type=1;
7343 82 tempitem.cost_amount[0]=8;
7344 82 tempitem.power=2;
7345 82 tempitem.misc1 = 20;
7346 82 break;
7347
7348 case iQuakeScroll:
7349 82 tempitem.misc1=0x10;
7350 82 tempitem.misc2=64;
7351 82 break;
7352
7353 case iL2QuakeScroll:
7354 82 tempitem.family=itype_quakescroll2;
7355 82 tempitem.fam_type=1;
7356 82 tempitem.power = 2;
7357 82 tempitem.misc1=0x20;
7358 82 tempitem.misc2=192;
7359 82 tempitem.cost_amount[0]=8;
7360 82 break;
7361
7362 case iChargeRing:
7363 82 tempitem.misc1=64;
7364 82 tempitem.misc2=128;
7365 82 break;
7366
7367 case iL2ChargeRing:
7368 82 tempitem.misc1=32;
7369 82 tempitem.misc2=64;
7370 82 break;
7371
7372 case iOldGlove:
7373 82 tempitem.flags |= item_flag1;
7374
7375 //fallthrough
7376 case iBombBagL4:
7377 case iWalletL3:
7378 case iQuiverL4:
7379 case iBracelet:
7380 410 tempitem.power = 1;
7381 410 break;
7382
7383 case iL2Bracelet:
7384 82 tempitem.power = 2;
7385 82 break;
7386
7387 case iMKey:
7388 82 tempitem.power=0xFF;
7389 82 tempitem.flags |= item_flag1;
7390 82 break;
7391 }
7392 20992 }
7393
7394
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 7)
7395 {
7396
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7397 {
7398 case iStoneAgony:
7399 case iStompBoots:
7400 case iPerilRing:
7401 case iWhimsicalRing:
7402 {
7403 328 reset_itembuf(&tempitem, i);
7404 328 strcpy(item_string[i],old_item_string[i]);
7405 328 break;
7406 }
7407 }
7408 20992 }
7409
7410
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 8) // May 2007: Some corrections.
7411 {
7412
7/7
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 20336 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7413 {
7414 case iMShield:
7415 82 tempitem.misc1|=sh_flame;
7416 82 tempitem.misc2|=sh_fireball|sh_magic;
7417
7418
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7419 {
7420 tempitem.misc2 |= sh_sword;
7421 }
7422
7423 // fallthrough
7424 case iShield:
7425 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7426
7427 // fallthrough
7428 case iSShield:
7429 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7430
7431
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7432 {
7433 tempitem.misc2 |= sh_rock;
7434 }
7435
7436 246 break;
7437
7438 case iWhispRing:
7439 82 tempitem.power=1;
7440 82 tempitem.flags|=item_gamedata|item_flag1;
7441 82 tempitem.misc1 = 3;
7442 82 break;
7443
7444 case iL2WhispRing:
7445 82 tempitem.power=0;
7446 82 tempitem.flags|=item_gamedata|item_flag1;
7447 82 tempitem.misc1 = 3;
7448 82 break;
7449
7450 case iL2Ladder:
7451 case iBow:
7452 case iCByrna:
7453 246 tempitem.power = 1;
7454 246 break;
7455 }
7456 20992 }
7457
7458
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 98304 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
119296 if(s_version < 9 && i==iClock)
7459 {
7460 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7461 82 }
7462
7463 //add the misc flag for bomb
7464
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 98304 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
119296 if(s_version < 10 && tempitem.family == itype_bomb)
7465 {
7466 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7467 82 }
7468
7469
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 98304 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
119296 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7470 {
7471 164 tempitem.flags = (tempitem.fam_type ? item_gamedata : item_none);
7472 164 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7473 164 }
7474
7475
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 12) // June 2007: More Misc. attributes.
7476 {
7477
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7478 {
7479 case iFBrang:
7480 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7481
7482 //fallthrough
7483 case iMBrang:
7484 164 tempitem.misc3 |= sh_sword|sh_magic;
7485
7486 //fallthrough
7487 case iHookshot:
7488 case iLongshot:
7489 //fallthrough
7490 328 tempitem.misc3 |= sh_fireball;
7491
7492 case iBrang:
7493 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7494 410 break;
7495 }
7496
7497
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 246 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 164 times.
✓ Branch 10 taken 9629 times.
✓ Branch 11 taken 164 times.
✓ Branch 12 taken 246 times.
✓ Branch 13 taken 9313 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
20992 switch(tempitem.family)
7498 {
7499 case itype_hoverboots:
7500 82 tempitem.usesound = WAV_ZN1HOVER;
7501 82 break;
7502
7503 case itype_wand:
7504 82 tempitem.usesound = WAV_WAND;
7505 82 break;
7506
7507 case itype_book:
7508 82 tempitem.usesound = WAV_FIRE;
7509 82 break;
7510
7511 case itype_arrow:
7512 246 tempitem.usesound = WAV_ARROW;
7513 246 break;
7514
7515 case itype_hookshot:
7516 164 tempitem.usesound = WAV_HOOKSHOT;
7517 164 break;
7518
7519 case itype_brang:
7520 246 tempitem.usesound = WAV_BRANG;
7521 246 break;
7522
7523 case itype_shield:
7524 246 tempitem.usesound = WAV_CHINK;
7525 246 break;
7526
7527 case itype_sword:
7528 9313 tempitem.usesound = WAV_SWORD;
7529 9313 break;
7530
7531 case itype_whistle:
7532 82 tempitem.usesound = WAV_WHISTLE;
7533 82 break;
7534
7535 case itype_hammer:
7536 82 tempitem.usesound = WAV_HAMMER;
7537 82 break;
7538
7539 case itype_divinefire:
7540 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7541 82 break;
7542
7543 case itype_divineescape:
7544 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7545 82 break;
7546
7547 case itype_divineprotection:
7548 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7549 82 break;
7550
7551 case itype_bomb:
7552 case itype_sbomb:
7553 case itype_quakescroll:
7554 case itype_quakescroll2:
7555 328 tempitem.usesound = WAV_BOMB;
7556 328 break;
7557
7558 case itype_spinscroll:
7559 case itype_spinscroll2:
7560 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7561 164 break;
7562 }
7563 20992 }
7564
7565
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 13) // July 2007
7566 {
7567
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7568 {
7569 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7570 82 tempitem.power = 1;
7571 82 tempitem.flags|=item_flag1;
7572 82 }
7573
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_wand)
7574 82 tempitem.flags|=item_flag1;
7575
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.family == itype_book)
7576 {
7577 82 tempitem.flags|=item_flag1;
7578 82 tempitem.power = 2;
7579 82 }
7580 20992 }
7581
7582
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 14) // August 2007
7583 {
7584
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.family == itype_fairy)
7585 {
7586 164 tempitem.usesound = WAV_SCALE;
7587
7588
1/2
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
164 if(tempitem.fam_type)
7589 164 tempitem.misc3=50;
7590 164 }
7591
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_potion)
7592 {
7593 164 tempitem.flags |= item_gain_old;
7594 164 }
7595 20992 }
7596
7597
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 17) // November 2007
7598 {
7599
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.family == itype_candle && !tempitem.wpn3)
7600 {
7601 tempitem.wpn3 = wFIRE;
7602 }
7603
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.family == itype_arrow && tempitem.power>4)
7604 {
7605 82 tempitem.flags|=item_flag1;
7606 82 }
7607 20992 }
7608
7609
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 18) // New Year's Eve 2007
7610 {
7611
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7612 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7613
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_bait)
7614 82 tempitem.misc1 = 768; // Frames until it goes
7615
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_triforcepiece)
7616 {
7617
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7618 {
7619 82 tempitem.misc2 = 1; // Cutscene 1
7620 82 tempitem.flags |= item_flag1; // Side Warp Out
7621 82 }
7622 164 }
7623 20992 }
7624
7625
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 19) // January 2008
7626 {
7627
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7628 {
7629
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 80 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7630
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 72 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7631 82 }
7632 20992 }
7633
7634
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 20) // October 2008
7635 {
7636
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7637 {
7638 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7639 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7640 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7641 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7642 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7643 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7644 82 }
7645 20992 }
7646
7647
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 21) // November 2008
7648 {
7649
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7650 {
7651 tempitem.flags &= ~item_unused;
7652
7653 if(tempitem.family == itype_sword ||
7654 tempitem.family == itype_wand ||
7655 tempitem.family == itype_candle ||
7656 tempitem.family == itype_cbyrna)
7657 {
7658 tempitem.flags |= item_flag4;
7659 }
7660 }
7661 20992 }
7662
7663
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 22) // September 2009
7664 {
7665
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7666 {
7667 164 tempitem.misc3 = tempitem.power/2;
7668 164 }
7669 20992 }
7670
7671
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 23) // March 2011
7672 {
7673
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_divinefire)
7674 82 tempitem.wpn5 = wFIRE;
7675
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.family == itype_book)
7676 82 tempitem.wpn2 = wFIRE;
7677 20992 }
7678
7679 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7680 // whether it was or not, and a lot of existing quests depended on the
7681 // incorrect behavior.
7682
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 20992 times.
119296 if(s_version < 25) // January 2012
7683 {
7684
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.family == itype_bombbag)
7685 328 tempitem.flags |= item_flag1;
7686
7687
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divinefire)
7688 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7689 20992 }
7690
7691
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7692 {
7693
60/60
✓ Branch 0 taken 17688 times.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 844 times.
✓ Branch 3 taken 610 times.
✓ Branch 4 taken 332 times.
✓ Branch 5 taken 286 times.
✓ Branch 6 taken 568 times.
✓ Branch 7 taken 623 times.
✓ Branch 8 taken 302 times.
✓ Branch 9 taken 906 times.
✓ Branch 10 taken 907 times.
✓ Branch 11 taken 564 times.
✓ Branch 12 taken 866 times.
✓ Branch 13 taken 568 times.
✓ Branch 14 taken 284 times.
✓ Branch 15 taken 568 times.
✓ Branch 16 taken 300 times.
✓ Branch 17 taken 284 times.
✓ Branch 18 taken 858 times.
✓ Branch 19 taken 286 times.
✓ Branch 20 taken 288 times.
✓ Branch 21 taken 570 times.
✓ Branch 22 taken 260 times.
✓ Branch 23 taken 286 times.
✓ Branch 24 taken 284 times.
✓ Branch 25 taken 284 times.
✓ Branch 26 taken 284 times.
✓ Branch 27 taken 300 times.
✓ Branch 28 taken 286 times.
✓ Branch 29 taken 286 times.
✓ Branch 30 taken 284 times.
✓ Branch 31 taken 288 times.
✓ Branch 32 taken 568 times.
✓ Branch 33 taken 1136 times.
✓ Branch 34 taken 783 times.
✓ Branch 35 taken 284 times.
✓ Branch 36 taken 553 times.
✓ Branch 37 taken 1136 times.
✓ Branch 38 taken 284 times.
✓ Branch 39 taken 284 times.
✓ Branch 40 taken 284 times.
✓ Branch 41 taken 284 times.
✓ Branch 42 taken 284 times.
✓ Branch 43 taken 570 times.
✓ Branch 44 taken 568 times.
✓ Branch 45 taken 284 times.
✓ Branch 46 taken 854 times.
✓ Branch 47 taken 856 times.
✓ Branch 48 taken 1144 times.
✓ Branch 49 taken 284 times.
✓ Branch 50 taken 284 times.
✓ Branch 51 taken 284 times.
✓ Branch 52 taken 284 times.
✓ Branch 53 taken 284 times.
✓ Branch 54 taken 310 times.
✓ Branch 55 taken 10813 times.
✓ Branch 56 taken 2917 times.
✓ Branch 57 taken 856 times.
✓ Branch 58 taken 3317 times.
✓ Branch 59 taken 11225 times.
73216 switch(tempitem.family)
7694 {
7695 case itype_sword:
7696 {
7697 17688 tempitem.flags &= ~(item_flag5);
7698 17688 tempitem.misc3 = 0;
7699 17688 tempitem.misc4 = 0;
7700 17688 tempitem.misc5 = 0;
7701 17688 tempitem.misc6 = 0;
7702 17688 tempitem.misc7 = 0;
7703 17688 tempitem.misc8 = 0;
7704 17688 tempitem.misc9 = 0;
7705 17688 tempitem.misc10 = 0;
7706 17688 tempitem.wpn4 = 0;
7707 17688 tempitem.wpn5 = 0;
7708 17688 tempitem.wpn6 = 0;
7709 17688 tempitem.wpn7 = 0;
7710 17688 tempitem.wpn8 = 0;
7711 17688 tempitem.wpn9 = 0;
7712 17688 tempitem.wpn10 = 0;
7713 17688 break;
7714 }
7715 case itype_brang:
7716 {
7717 858 tempitem.flags &= ~(item_flag4 | item_flag5);
7718 858 tempitem.misc2 = 0;
7719 858 tempitem.misc5 = 0;
7720 858 tempitem.misc6 = 0;
7721 858 tempitem.misc7 = 0;
7722 858 tempitem.misc8 = 0;
7723 858 tempitem.misc9 = 0;
7724 858 tempitem.misc10 = 0;
7725 858 tempitem.wpn4 = 0;
7726 858 tempitem.wpn5 = 0;
7727 858 tempitem.wpn6 = 0;
7728 858 tempitem.wpn7 = 0;
7729 858 tempitem.wpn8 = 0;
7730 858 tempitem.wpn9 = 0;
7731 858 tempitem.wpn10 = 0;
7732 858 break;
7733 }
7734 case itype_arrow:
7735 {
7736 844 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7737 844 tempitem.misc2 = 0;
7738 844 tempitem.misc3 = 0;
7739 844 tempitem.misc4 = 0;
7740 844 tempitem.misc5 = 0;
7741 844 tempitem.misc6 = 0;
7742 844 tempitem.misc7 = 0;
7743 844 tempitem.misc8 = 0;
7744 844 tempitem.misc9 = 0;
7745 844 tempitem.misc10 = 0;
7746 844 tempitem.wpn4 = 0;
7747 844 tempitem.wpn5 = 0;
7748 844 tempitem.wpn6 = 0;
7749 844 tempitem.wpn7 = 0;
7750 844 tempitem.wpn8 = 0;
7751 844 tempitem.wpn9 = 0;
7752 844 tempitem.wpn10 = 0;
7753 844 break;
7754 }
7755 case itype_candle:
7756 {
7757 610 tempitem.flags &= ~ (item_flag3 | item_flag5);
7758 610 tempitem.misc1 = 0;
7759 610 tempitem.misc2 = 0;
7760 610 tempitem.misc3 = 0;
7761 610 tempitem.misc4 = 0;
7762 610 tempitem.misc5 = 0;
7763 610 tempitem.misc6 = 0;
7764 610 tempitem.misc7 = 0;
7765 610 tempitem.misc8 = 0;
7766 610 tempitem.misc9 = 0;
7767 610 tempitem.misc10 = 0;
7768 610 tempitem.wpn4 = 0;
7769 610 tempitem.wpn5 = 0;
7770 610 tempitem.wpn6 = 0;
7771 610 tempitem.wpn7 = 0;
7772 610 tempitem.wpn8 = 0;
7773 610 tempitem.wpn9 = 0;
7774 610 tempitem.wpn10 = 0;
7775 610 break;
7776 }
7777 case itype_whistle:
7778 {
7779 332 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7780 332 tempitem.misc3 = 0;
7781 332 tempitem.misc4 = 0;
7782 332 tempitem.misc5 = 0;
7783 332 tempitem.misc6 = 0;
7784 332 tempitem.misc7 = 0;
7785 332 tempitem.misc8 = 0;
7786 332 tempitem.misc9 = 0;
7787 332 tempitem.misc10 = 0;
7788 332 tempitem.wpn2 = 0;
7789 332 tempitem.wpn3 = 0;
7790 332 tempitem.wpn4 = 0;
7791 332 tempitem.wpn5 = 0;
7792 332 tempitem.wpn6 = 0;
7793 332 tempitem.wpn7 = 0;
7794 332 tempitem.wpn8 = 0;
7795 332 tempitem.wpn9 = 0;
7796 332 tempitem.wpn10 = 0;
7797 332 break;
7798 }
7799 case itype_bait:
7800 {
7801 286 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7802 286 tempitem.misc2 = 0;
7803 286 tempitem.misc3 = 0;
7804 286 tempitem.misc4 = 0;
7805 286 tempitem.misc5 = 0;
7806 286 tempitem.misc6 = 0;
7807 286 tempitem.misc7 = 0;
7808 286 tempitem.misc8 = 0;
7809 286 tempitem.misc9 = 0;
7810 286 tempitem.misc10 = 0;
7811 286 tempitem.wpn2 = 0;
7812 286 tempitem.wpn3 = 0;
7813 286 tempitem.wpn4 = 0;
7814 286 tempitem.wpn5 = 0;
7815 286 tempitem.wpn6 = 0;
7816 286 tempitem.wpn7 = 0;
7817 286 tempitem.wpn8 = 0;
7818 286 tempitem.wpn9 = 0;
7819 286 tempitem.wpn10 = 0;
7820 286 break;
7821 }
7822 case itype_letter:
7823 {
7824 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7825 568 tempitem.misc1 = 0;
7826 568 tempitem.misc2 = 0;
7827 568 tempitem.misc3 = 0;
7828 568 tempitem.misc4 = 0;
7829 568 tempitem.misc5 = 0;
7830 568 tempitem.misc6 = 0;
7831 568 tempitem.misc7 = 0;
7832 568 tempitem.misc8 = 0;
7833 568 tempitem.misc9 = 0;
7834 568 tempitem.misc10 = 0;
7835 568 tempitem.wpn = 0;
7836 568 tempitem.wpn2 = 0;
7837 568 tempitem.wpn3 = 0;
7838 568 tempitem.wpn4 = 0;
7839 568 tempitem.wpn5 = 0;
7840 568 tempitem.wpn6 = 0;
7841 568 tempitem.wpn7 = 0;
7842 568 tempitem.wpn8 = 0;
7843 568 tempitem.wpn9 = 0;
7844 568 tempitem.wpn10 = 0;
7845 568 break;
7846 }
7847 case itype_potion:
7848 {
7849 623 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
7850 623 tempitem.misc3 = 0;
7851 623 tempitem.misc4 = 0;
7852 623 tempitem.misc5 = 0;
7853 623 tempitem.misc6 = 0;
7854 623 tempitem.misc7 = 0;
7855 623 tempitem.misc8 = 0;
7856 623 tempitem.misc9 = 0;
7857 623 tempitem.misc10 = 0;
7858 623 tempitem.wpn = 0;
7859 623 tempitem.wpn2 = 0;
7860 623 tempitem.wpn3 = 0;
7861 623 tempitem.wpn4 = 0;
7862 623 tempitem.wpn5 = 0;
7863 623 tempitem.wpn6 = 0;
7864 623 tempitem.wpn7 = 0;
7865 623 tempitem.wpn8 = 0;
7866 623 tempitem.wpn9 = 0;
7867 623 tempitem.wpn10 = 0;
7868 623 break;
7869 }
7870 case itype_wand:
7871 {
7872 302 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
7873 302 tempitem.misc1 = 0;
7874 302 tempitem.misc2 = 0;
7875 302 tempitem.misc3 = 0;
7876 302 tempitem.misc4 = 0;
7877 302 tempitem.misc5 = 0;
7878 302 tempitem.misc6 = 0;
7879 302 tempitem.misc7 = 0;
7880 302 tempitem.misc8 = 0;
7881 302 tempitem.misc9 = 0;
7882 302 tempitem.misc10 = 0;
7883 302 tempitem.wpn4 = 0;
7884 302 tempitem.wpn5 = 0;
7885 302 tempitem.wpn6 = 0;
7886 302 tempitem.wpn7 = 0;
7887 302 tempitem.wpn8 = 0;
7888 302 tempitem.wpn9 = 0;
7889 302 tempitem.wpn10 = 0;
7890 302 break;
7891 }
7892 case itype_ring:
7893 {
7894 906 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7895 906 tempitem.misc2 = 0;
7896 906 tempitem.misc3 = 0;
7897 906 tempitem.misc4 = 0;
7898 906 tempitem.misc5 = 0;
7899 906 tempitem.misc6 = 0;
7900 906 tempitem.misc7 = 0;
7901 906 tempitem.misc8 = 0;
7902 906 tempitem.misc9 = 0;
7903 906 tempitem.misc10 = 0;
7904 906 tempitem.wpn = 0;
7905 906 tempitem.wpn2 = 0;
7906 906 tempitem.wpn3 = 0;
7907 906 tempitem.wpn4 = 0;
7908 906 tempitem.wpn5 = 0;
7909 906 tempitem.wpn6 = 0;
7910 906 tempitem.wpn7 = 0;
7911 906 tempitem.wpn8 = 0;
7912 906 tempitem.wpn9 = 0;
7913 906 tempitem.wpn10 = 0;
7914 906 break;
7915 }
7916 case itype_wallet:
7917 {
7918 907 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7919 907 tempitem.misc3 = 0;
7920 907 tempitem.misc4 = 0;
7921 907 tempitem.misc5 = 0;
7922 907 tempitem.misc6 = 0;
7923 907 tempitem.misc7 = 0;
7924 907 tempitem.misc8 = 0;
7925 907 tempitem.misc9 = 0;
7926 907 tempitem.misc10 = 0;
7927 907 tempitem.wpn = 0;
7928 907 tempitem.wpn2 = 0;
7929 907 tempitem.wpn3 = 0;
7930 907 tempitem.wpn4 = 0;
7931 907 tempitem.wpn5 = 0;
7932 907 tempitem.wpn6 = 0;
7933 907 tempitem.wpn7 = 0;
7934 907 tempitem.wpn8 = 0;
7935 907 tempitem.wpn9 = 0;
7936 907 tempitem.wpn10 = 0;
7937 907 break;
7938 }
7939 case itype_amulet:
7940 {
7941 564 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7942 564 tempitem.misc1 = 0;
7943 564 tempitem.misc2 = 0;
7944 564 tempitem.misc3 = 0;
7945 564 tempitem.misc4 = 0;
7946 564 tempitem.misc5 = 0;
7947 564 tempitem.misc6 = 0;
7948 564 tempitem.misc7 = 0;
7949 564 tempitem.misc8 = 0;
7950 564 tempitem.misc9 = 0;
7951 564 tempitem.misc10 = 0;
7952 564 tempitem.wpn = 0;
7953 564 tempitem.wpn2 = 0;
7954 564 tempitem.wpn3 = 0;
7955 564 tempitem.wpn4 = 0;
7956 564 tempitem.wpn5 = 0;
7957 564 tempitem.wpn6 = 0;
7958 564 tempitem.wpn7 = 0;
7959 564 tempitem.wpn8 = 0;
7960 564 tempitem.wpn9 = 0;
7961 564 tempitem.wpn10 = 0;
7962 564 break;
7963 }
7964 case itype_shield:
7965 {
7966 866 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7967 866 tempitem.misc3 = 0;
7968 866 tempitem.misc4 = 0;
7969 866 tempitem.misc5 = 0;
7970 866 tempitem.misc6 = 0;
7971 866 tempitem.misc7 = 0;
7972 866 tempitem.misc8 = 0;
7973 866 tempitem.misc9 = 0;
7974 866 tempitem.misc10 = 0;
7975 866 tempitem.wpn = 0;
7976 866 tempitem.wpn2 = 0;
7977 866 tempitem.wpn3 = 0;
7978 866 tempitem.wpn4 = 0;
7979 866 tempitem.wpn5 = 0;
7980 866 tempitem.wpn6 = 0;
7981 866 tempitem.wpn7 = 0;
7982 866 tempitem.wpn8 = 0;
7983 866 tempitem.wpn9 = 0;
7984 866 tempitem.wpn10 = 0;
7985 866 break;
7986 }
7987 case itype_bow:
7988 {
7989 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7990 568 tempitem.misc1 = 0;
7991 568 tempitem.misc2 = 0;
7992 568 tempitem.misc3 = 0;
7993 568 tempitem.misc4 = 0;
7994 568 tempitem.misc5 = 0;
7995 568 tempitem.misc6 = 0;
7996 568 tempitem.misc7 = 0;
7997 568 tempitem.misc8 = 0;
7998 568 tempitem.misc9 = 0;
7999 568 tempitem.misc10 = 0;
8000 568 tempitem.wpn = 0;
8001 568 tempitem.wpn2 = 0;
8002 568 tempitem.wpn3 = 0;
8003 568 tempitem.wpn4 = 0;
8004 568 tempitem.wpn5 = 0;
8005 568 tempitem.wpn6 = 0;
8006 568 tempitem.wpn7 = 0;
8007 568 tempitem.wpn8 = 0;
8008 568 tempitem.wpn9 = 0;
8009 568 tempitem.wpn10 = 0;
8010 568 break;
8011 }
8012 case itype_raft:
8013 {
8014 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8015 284 tempitem.misc1 = 0;
8016 284 tempitem.misc2 = 0;
8017 284 tempitem.misc3 = 0;
8018 284 tempitem.misc4 = 0;
8019 284 tempitem.misc5 = 0;
8020 284 tempitem.misc6 = 0;
8021 284 tempitem.misc7 = 0;
8022 284 tempitem.misc8 = 0;
8023 284 tempitem.misc9 = 0;
8024 284 tempitem.misc10 = 0;
8025 284 tempitem.wpn = 0;
8026 284 tempitem.wpn2 = 0;
8027 284 tempitem.wpn3 = 0;
8028 284 tempitem.wpn4 = 0;
8029 284 tempitem.wpn5 = 0;
8030 284 tempitem.wpn6 = 0;
8031 284 tempitem.wpn7 = 0;
8032 284 tempitem.wpn8 = 0;
8033 284 tempitem.wpn9 = 0;
8034 284 tempitem.wpn10 = 0;
8035 284 break;
8036 }
8037 case itype_ladder:
8038 {
8039 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8040 568 tempitem.misc1 = 0;
8041 568 tempitem.misc2 = 0;
8042 568 tempitem.misc3 = 0;
8043 568 tempitem.misc4 = 0;
8044 568 tempitem.misc5 = 0;
8045 568 tempitem.misc6 = 0;
8046 568 tempitem.misc7 = 0;
8047 568 tempitem.misc8 = 0;
8048 568 tempitem.misc9 = 0;
8049 568 tempitem.misc10 = 0;
8050 568 tempitem.wpn = 0;
8051 568 tempitem.wpn2 = 0;
8052 568 tempitem.wpn3 = 0;
8053 568 tempitem.wpn4 = 0;
8054 568 tempitem.wpn5 = 0;
8055 568 tempitem.wpn6 = 0;
8056 568 tempitem.wpn7 = 0;
8057 568 tempitem.wpn8 = 0;
8058 568 tempitem.wpn9 = 0;
8059 568 tempitem.wpn10 = 0;
8060 568 break;
8061 }
8062 case itype_book:
8063 {
8064 300 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8065 300 tempitem.misc1 = 0;
8066 300 tempitem.misc2 = 0;
8067 300 tempitem.misc3 = 0;
8068 300 tempitem.misc4 = 0;
8069 300 tempitem.misc5 = 0;
8070 300 tempitem.misc6 = 0;
8071 300 tempitem.misc7 = 0;
8072 300 tempitem.misc8 = 0;
8073 300 tempitem.misc9 = 0;
8074 300 tempitem.misc10 = 0;
8075 300 tempitem.wpn3 = 0;
8076 300 tempitem.wpn4 = 0;
8077 300 tempitem.wpn5 = 0;
8078 300 tempitem.wpn6 = 0;
8079 300 tempitem.wpn7 = 0;
8080 300 tempitem.wpn8 = 0;
8081 300 tempitem.wpn9 = 0;
8082 300 tempitem.wpn10 = 0;
8083 300 break;
8084 }
8085 case itype_magickey:
8086 {
8087 284 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8088 284 tempitem.misc1 = 0;
8089 284 tempitem.misc2 = 0;
8090 284 tempitem.misc3 = 0;
8091 284 tempitem.misc4 = 0;
8092 284 tempitem.misc5 = 0;
8093 284 tempitem.misc6 = 0;
8094 284 tempitem.misc7 = 0;
8095 284 tempitem.misc8 = 0;
8096 284 tempitem.misc9 = 0;
8097 284 tempitem.misc10 = 0;
8098 284 tempitem.wpn = 0;
8099 284 tempitem.wpn2 = 0;
8100 284 tempitem.wpn3 = 0;
8101 284 tempitem.wpn4 = 0;
8102 284 tempitem.wpn5 = 0;
8103 284 tempitem.wpn6 = 0;
8104 284 tempitem.wpn7 = 0;
8105 284 tempitem.wpn8 = 0;
8106 284 tempitem.wpn9 = 0;
8107 284 tempitem.wpn10 = 0;
8108 284 break;
8109 }
8110 case itype_bracelet:
8111 {
8112 858 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8113 858 tempitem.misc1 = 0;
8114 858 tempitem.misc2 = 0;
8115 858 tempitem.misc3 = 0;
8116 858 tempitem.misc4 = 0;
8117 858 tempitem.misc5 = 0;
8118 858 tempitem.misc6 = 0;
8119 858 tempitem.misc7 = 0;
8120 858 tempitem.misc8 = 0;
8121 858 tempitem.misc9 = 0;
8122 858 tempitem.misc10 = 0;
8123 858 tempitem.wpn = 0;
8124 858 tempitem.wpn2 = 0;
8125 858 tempitem.wpn3 = 0;
8126 858 tempitem.wpn4 = 0;
8127 858 tempitem.wpn5 = 0;
8128 858 tempitem.wpn6 = 0;
8129 858 tempitem.wpn7 = 0;
8130 858 tempitem.wpn8 = 0;
8131 858 tempitem.wpn9 = 0;
8132 858 tempitem.wpn10 = 0;
8133 858 break;
8134 }
8135 case itype_flippers:
8136 {
8137 286 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8138 286 tempitem.misc1 = 0;
8139 286 tempitem.misc2 = 0;
8140 286 tempitem.misc3 = 0;
8141 286 tempitem.misc4 = 0;
8142 286 tempitem.misc5 = 0;
8143 286 tempitem.misc6 = 0;
8144 286 tempitem.misc7 = 0;
8145 286 tempitem.misc8 = 0;
8146 286 tempitem.misc9 = 0;
8147 286 tempitem.misc10 = 0;
8148 286 tempitem.wpn = 0;
8149 286 tempitem.wpn2 = 0;
8150 286 tempitem.wpn3 = 0;
8151 286 tempitem.wpn4 = 0;
8152 286 tempitem.wpn5 = 0;
8153 286 tempitem.wpn6 = 0;
8154 286 tempitem.wpn7 = 0;
8155 286 tempitem.wpn8 = 0;
8156 286 tempitem.wpn9 = 0;
8157 286 tempitem.wpn10 = 0;
8158 286 break;
8159 }
8160 case itype_boots:
8161 {
8162 288 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8163 288 tempitem.misc1 = 0;
8164 288 tempitem.misc2 = 0;
8165 288 tempitem.misc3 = 0;
8166 288 tempitem.misc4 = 0;
8167 288 tempitem.misc5 = 0;
8168 288 tempitem.misc6 = 0;
8169 288 tempitem.misc7 = 0;
8170 288 tempitem.misc8 = 0;
8171 288 tempitem.misc9 = 0;
8172 288 tempitem.misc10 = 0;
8173 288 tempitem.wpn = 0;
8174 288 tempitem.wpn2 = 0;
8175 288 tempitem.wpn3 = 0;
8176 288 tempitem.wpn4 = 0;
8177 288 tempitem.wpn5 = 0;
8178 288 tempitem.wpn6 = 0;
8179 288 tempitem.wpn7 = 0;
8180 288 tempitem.wpn8 = 0;
8181 288 tempitem.wpn9 = 0;
8182 288 tempitem.wpn10 = 0;
8183 288 break;
8184 }
8185 case itype_hookshot:
8186 {
8187 570 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8188 570 tempitem.misc5 = 0;
8189 570 tempitem.misc6 = 0;
8190 570 tempitem.misc7 = 0;
8191 570 tempitem.misc8 = 0;
8192 570 tempitem.misc9 = 0;
8193 570 tempitem.misc10 = 0;
8194 570 tempitem.wpn5 = 0;
8195 570 tempitem.wpn6 = 0;
8196 570 tempitem.wpn7 = 0;
8197 570 tempitem.wpn8 = 0;
8198 570 tempitem.wpn9 = 0;
8199 570 tempitem.wpn10 = 0;
8200 570 break;
8201 }
8202 case itype_lens:
8203 {
8204 260 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8205 260 tempitem.misc2 = 0;
8206 260 tempitem.misc3 = 0;
8207 260 tempitem.misc4 = 0;
8208 260 tempitem.misc5 = 0;
8209 260 tempitem.misc6 = 0;
8210 260 tempitem.misc7 = 0;
8211 260 tempitem.misc8 = 0;
8212 260 tempitem.misc9 = 0;
8213 260 tempitem.misc10 = 0;
8214 260 tempitem.wpn = 0;
8215 260 tempitem.wpn2 = 0;
8216 260 tempitem.wpn3 = 0;
8217 260 tempitem.wpn4 = 0;
8218 260 tempitem.wpn5 = 0;
8219 260 tempitem.wpn6 = 0;
8220 260 tempitem.wpn7 = 0;
8221 260 tempitem.wpn8 = 0;
8222 260 tempitem.wpn9 = 0;
8223 260 tempitem.wpn10 = 0;
8224 260 break;
8225 }
8226 case itype_hammer:
8227 {
8228 286 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8229 286 tempitem.misc1 = 0;
8230 286 tempitem.misc2 = 0;
8231 286 tempitem.misc3 = 0;
8232 286 tempitem.misc4 = 0;
8233 286 tempitem.misc5 = 0;
8234 286 tempitem.misc6 = 0;
8235 286 tempitem.misc7 = 0;
8236 286 tempitem.misc8 = 0;
8237 286 tempitem.misc9 = 0;
8238 286 tempitem.misc10 = 0;
8239 286 tempitem.wpn3 = 0;
8240 286 tempitem.wpn4 = 0;
8241 286 tempitem.wpn5 = 0;
8242 286 tempitem.wpn6 = 0;
8243 286 tempitem.wpn7 = 0;
8244 286 tempitem.wpn8 = 0;
8245 286 tempitem.wpn9 = 0;
8246 286 tempitem.wpn10 = 0;
8247 286 break;
8248 }
8249 case itype_divinefire:
8250 {
8251 284 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8252 284 tempitem.misc3 = 0;
8253 284 tempitem.misc4 = 0;
8254 284 tempitem.misc5 = 0;
8255 284 tempitem.misc6 = 0;
8256 284 tempitem.misc7 = 0;
8257 284 tempitem.misc8 = 0;
8258 284 tempitem.misc9 = 0;
8259 284 tempitem.misc10 = 0;
8260 284 tempitem.wpn6 = 0;
8261 284 tempitem.wpn7 = 0;
8262 284 tempitem.wpn8 = 0;
8263 284 tempitem.wpn9 = 0;
8264 284 tempitem.wpn10 = 0;
8265 284 break;
8266 }
8267 case itype_divineescape:
8268 {
8269 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8270 284 tempitem.misc2 = 0;
8271 284 tempitem.misc3 = 0;
8272 284 tempitem.misc4 = 0;
8273 284 tempitem.misc5 = 0;
8274 284 tempitem.misc6 = 0;
8275 284 tempitem.misc7 = 0;
8276 284 tempitem.misc8 = 0;
8277 284 tempitem.misc9 = 0;
8278 284 tempitem.misc10 = 0;
8279 284 tempitem.wpn = 0;
8280 284 tempitem.wpn2 = 0;
8281 284 tempitem.wpn3 = 0;
8282 284 tempitem.wpn4 = 0;
8283 284 tempitem.wpn5 = 0;
8284 284 tempitem.wpn6 = 0;
8285 284 tempitem.wpn7 = 0;
8286 284 tempitem.wpn8 = 0;
8287 284 tempitem.wpn9 = 0;
8288 284 tempitem.wpn10 = 0;
8289 284 break;
8290 }
8291 case itype_divineprotection:
8292 {
8293 284 tempitem.flags &= ~ (item_flag5);
8294 284 tempitem.misc2 = 0;
8295 284 tempitem.misc3 = 0;
8296 284 tempitem.misc4 = 0;
8297 284 tempitem.misc5 = 0;
8298 284 tempitem.misc6 = 0;
8299 284 tempitem.misc7 = 0;
8300 284 tempitem.misc8 = 0;
8301 284 tempitem.misc9 = 0;
8302 284 tempitem.misc10 = 0;
8303 284 break;
8304 }
8305 case itype_bomb:
8306 {
8307 300 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8308 300 tempitem.misc4 = 0;
8309 300 tempitem.misc5 = 0;
8310 300 tempitem.misc6 = 0;
8311 300 tempitem.misc7 = 0;
8312 300 tempitem.misc8 = 0;
8313 300 tempitem.misc9 = 0;
8314 300 tempitem.misc10 = 0;
8315 300 tempitem.wpn3 = 0;
8316 300 tempitem.wpn4 = 0;
8317 300 tempitem.wpn5 = 0;
8318 300 tempitem.wpn6 = 0;
8319 300 tempitem.wpn7 = 0;
8320 300 tempitem.wpn8 = 0;
8321 300 tempitem.wpn9 = 0;
8322 300 tempitem.wpn10 = 0;
8323 300 break;
8324 }
8325 case itype_sbomb:
8326 {
8327 286 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8328 286 tempitem.misc4 = 0;
8329 286 tempitem.misc5 = 0;
8330 286 tempitem.misc6 = 0;
8331 286 tempitem.misc7 = 0;
8332 286 tempitem.misc8 = 0;
8333 286 tempitem.misc9 = 0;
8334 286 tempitem.misc10 = 0;
8335 286 tempitem.wpn3 = 0;
8336 286 tempitem.wpn4 = 0;
8337 286 tempitem.wpn5 = 0;
8338 286 tempitem.wpn6 = 0;
8339 286 tempitem.wpn7 = 0;
8340 286 tempitem.wpn8 = 0;
8341 286 tempitem.wpn9 = 0;
8342 286 tempitem.wpn10 = 0;
8343 286 break;
8344 }
8345 case itype_clock:
8346 {
8347 286 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8348 286 tempitem.misc2 = 0;
8349 286 tempitem.misc3 = 0;
8350 286 tempitem.misc4 = 0;
8351 286 tempitem.misc5 = 0;
8352 286 tempitem.misc6 = 0;
8353 286 tempitem.misc7 = 0;
8354 286 tempitem.misc8 = 0;
8355 286 tempitem.misc9 = 0;
8356 286 tempitem.misc10 = 0;
8357 286 tempitem.wpn = 0;
8358 286 tempitem.wpn2 = 0;
8359 286 tempitem.wpn3 = 0;
8360 286 tempitem.wpn4 = 0;
8361 286 tempitem.wpn5 = 0;
8362 286 tempitem.wpn6 = 0;
8363 286 tempitem.wpn7 = 0;
8364 286 tempitem.wpn8 = 0;
8365 286 tempitem.wpn9 = 0;
8366 286 tempitem.wpn10 = 0;
8367 286 break;
8368 }
8369 case itype_key:
8370 {
8371 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8372 284 tempitem.misc1 = 0;
8373 284 tempitem.misc2 = 0;
8374 284 tempitem.misc3 = 0;
8375 284 tempitem.misc4 = 0;
8376 284 tempitem.misc5 = 0;
8377 284 tempitem.misc6 = 0;
8378 284 tempitem.misc7 = 0;
8379 284 tempitem.misc8 = 0;
8380 284 tempitem.misc9 = 0;
8381 284 tempitem.misc10 = 0;
8382 284 tempitem.wpn = 0;
8383 284 tempitem.wpn2 = 0;
8384 284 tempitem.wpn3 = 0;
8385 284 tempitem.wpn4 = 0;
8386 284 tempitem.wpn5 = 0;
8387 284 tempitem.wpn6 = 0;
8388 284 tempitem.wpn7 = 0;
8389 284 tempitem.wpn8 = 0;
8390 284 tempitem.wpn9 = 0;
8391 284 tempitem.wpn10 = 0;
8392 284 break;
8393 }
8394 case itype_magiccontainer:
8395 {
8396 288 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8397 288 tempitem.misc1 = 0;
8398 288 tempitem.misc2 = 0;
8399 288 tempitem.misc3 = 0;
8400 288 tempitem.misc4 = 0;
8401 288 tempitem.misc5 = 0;
8402 288 tempitem.misc6 = 0;
8403 288 tempitem.misc7 = 0;
8404 288 tempitem.misc8 = 0;
8405 288 tempitem.misc9 = 0;
8406 288 tempitem.misc10 = 0;
8407 288 tempitem.wpn = 0;
8408 288 tempitem.wpn2 = 0;
8409 288 tempitem.wpn3 = 0;
8410 288 tempitem.wpn4 = 0;
8411 288 tempitem.wpn5 = 0;
8412 288 tempitem.wpn6 = 0;
8413 288 tempitem.wpn7 = 0;
8414 288 tempitem.wpn8 = 0;
8415 288 tempitem.wpn9 = 0;
8416 288 tempitem.wpn10 = 0;
8417 288 break;
8418 }
8419 case itype_triforcepiece:
8420 {
8421 568 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8422 568 tempitem.misc3 = 0;
8423 568 tempitem.misc4 = 0;
8424 568 tempitem.misc5 = 0;
8425 568 tempitem.misc6 = 0;
8426 568 tempitem.misc7 = 0;
8427 568 tempitem.misc8 = 0;
8428 568 tempitem.misc9 = 0;
8429 568 tempitem.misc10 = 0;
8430 568 tempitem.wpn = 0;
8431 568 tempitem.wpn2 = 0;
8432 568 tempitem.wpn3 = 0;
8433 568 tempitem.wpn4 = 0;
8434 568 tempitem.wpn5 = 0;
8435 568 tempitem.wpn6 = 0;
8436 568 tempitem.wpn7 = 0;
8437 568 tempitem.wpn8 = 0;
8438 568 tempitem.wpn9 = 0;
8439 568 tempitem.wpn10 = 0;
8440 568 break;
8441 }
8442 case itype_map: case itype_compass: case itype_bosskey:
8443 {
8444 856 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8445 856 tempitem.misc1 = 0;
8446 856 tempitem.misc2 = 0;
8447 856 tempitem.misc3 = 0;
8448 856 tempitem.misc4 = 0;
8449 856 tempitem.misc5 = 0;
8450 856 tempitem.misc6 = 0;
8451 856 tempitem.misc7 = 0;
8452 856 tempitem.misc8 = 0;
8453 856 tempitem.misc9 = 0;
8454 856 tempitem.misc10 = 0;
8455 856 tempitem.wpn = 0;
8456 856 tempitem.wpn2 = 0;
8457 856 tempitem.wpn3 = 0;
8458 856 tempitem.wpn4 = 0;
8459 856 tempitem.wpn5 = 0;
8460 856 tempitem.wpn6 = 0;
8461 856 tempitem.wpn7 = 0;
8462 856 tempitem.wpn8 = 0;
8463 856 tempitem.wpn9 = 0;
8464 856 tempitem.wpn10 = 0;
8465 856 break;
8466 }
8467 case itype_quiver:
8468 {
8469 1136 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8470 1136 tempitem.misc3 = 0;
8471 1136 tempitem.misc4 = 0;
8472 1136 tempitem.misc5 = 0;
8473 1136 tempitem.misc6 = 0;
8474 1136 tempitem.misc7 = 0;
8475 1136 tempitem.misc8 = 0;
8476 1136 tempitem.misc9 = 0;
8477 1136 tempitem.misc10 = 0;
8478 1136 tempitem.wpn = 0;
8479 1136 tempitem.wpn2 = 0;
8480 1136 tempitem.wpn3 = 0;
8481 1136 tempitem.wpn4 = 0;
8482 1136 tempitem.wpn5 = 0;
8483 1136 tempitem.wpn6 = 0;
8484 1136 tempitem.wpn7 = 0;
8485 1136 tempitem.wpn8 = 0;
8486 1136 tempitem.wpn9 = 0;
8487 1136 tempitem.wpn10 = 0;
8488 1136 break;
8489 }
8490 case itype_lkey:
8491 {
8492 783 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8493 783 tempitem.misc1 = 0;
8494 783 tempitem.misc2 = 0;
8495 783 tempitem.misc3 = 0;
8496 783 tempitem.misc4 = 0;
8497 783 tempitem.misc5 = 0;
8498 783 tempitem.misc6 = 0;
8499 783 tempitem.misc7 = 0;
8500 783 tempitem.misc8 = 0;
8501 783 tempitem.misc9 = 0;
8502 783 tempitem.misc10 = 0;
8503 783 tempitem.wpn = 0;
8504 783 tempitem.wpn2 = 0;
8505 783 tempitem.wpn3 = 0;
8506 783 tempitem.wpn4 = 0;
8507 783 tempitem.wpn5 = 0;
8508 783 tempitem.wpn6 = 0;
8509 783 tempitem.wpn7 = 0;
8510 783 tempitem.wpn8 = 0;
8511 783 tempitem.wpn9 = 0;
8512 783 tempitem.wpn10 = 0;
8513 783 break;
8514 }
8515 case itype_cbyrna:
8516 {
8517 284 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8518 284 tempitem.misc4 = 0;
8519 284 tempitem.misc5 = 0;
8520 284 tempitem.misc6 = 0;
8521 284 tempitem.misc7 = 0;
8522 284 tempitem.misc8 = 0;
8523 284 tempitem.misc9 = 0;
8524 284 tempitem.misc10 = 0;
8525 284 tempitem.wpn6 = 0;
8526 284 tempitem.wpn7 = 0;
8527 284 tempitem.wpn8 = 0;
8528 284 tempitem.wpn9 = 0;
8529 284 tempitem.wpn10 = 0;
8530 284 break;
8531 }
8532 case itype_rupee: case itype_arrowammo:
8533 {
8534 3317 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8535 3317 tempitem.misc1 = 0;
8536 3317 tempitem.misc2 = 0;
8537 3317 tempitem.misc3 = 0;
8538 3317 tempitem.misc4 = 0;
8539 3317 tempitem.misc5 = 0;
8540 3317 tempitem.misc6 = 0;
8541 3317 tempitem.misc7 = 0;
8542 3317 tempitem.misc8 = 0;
8543 3317 tempitem.misc9 = 0;
8544 3317 tempitem.misc10 = 0;
8545 3317 tempitem.wpn = 0;
8546 3317 tempitem.wpn2 = 0;
8547 3317 tempitem.wpn3 = 0;
8548 3317 tempitem.wpn4 = 0;
8549 3317 tempitem.wpn5 = 0;
8550 3317 tempitem.wpn6 = 0;
8551 3317 tempitem.wpn7 = 0;
8552 3317 tempitem.wpn8 = 0;
8553 3317 tempitem.wpn9 = 0;
8554 3317 tempitem.wpn10 = 0;
8555 3317 break;
8556 }
8557 case itype_fairy:
8558 {
8559 553 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8560 553 tempitem.misc4 = 0;
8561 553 tempitem.misc5 = 0;
8562 553 tempitem.misc6 = 0;
8563 553 tempitem.misc7 = 0;
8564 553 tempitem.misc8 = 0;
8565 553 tempitem.misc9 = 0;
8566 553 tempitem.misc10 = 0;
8567 553 tempitem.wpn = 0;
8568 553 tempitem.wpn2 = 0;
8569 553 tempitem.wpn3 = 0;
8570 553 tempitem.wpn4 = 0;
8571 553 tempitem.wpn5 = 0;
8572 553 tempitem.wpn6 = 0;
8573 553 tempitem.wpn7 = 0;
8574 553 tempitem.wpn8 = 0;
8575 553 tempitem.wpn9 = 0;
8576 553 tempitem.wpn10 = 0;
8577 553 break;
8578 }
8579 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8580 {
8581 2917 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8582 2917 tempitem.misc1 = 0;
8583 2917 tempitem.misc2 = 0;
8584 2917 tempitem.misc3 = 0;
8585 2917 tempitem.misc4 = 0;
8586 2917 tempitem.misc5 = 0;
8587 2917 tempitem.misc6 = 0;
8588 2917 tempitem.misc7 = 0;
8589 2917 tempitem.misc8 = 0;
8590 2917 tempitem.misc9 = 0;
8591 2917 tempitem.misc10 = 0;
8592 2917 tempitem.wpn = 0;
8593 2917 tempitem.wpn2 = 0;
8594 2917 tempitem.wpn3 = 0;
8595 2917 tempitem.wpn4 = 0;
8596 2917 tempitem.wpn5 = 0;
8597 2917 tempitem.wpn6 = 0;
8598 2917 tempitem.wpn7 = 0;
8599 2917 tempitem.wpn8 = 0;
8600 2917 tempitem.wpn9 = 0;
8601 2917 tempitem.wpn10 = 0;
8602 2917 break;
8603 }
8604 case itype_bombbag:
8605 {
8606 1136 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8607 1136 tempitem.misc3 = 0;
8608 1136 tempitem.misc4 = 0;
8609 1136 tempitem.misc5 = 0;
8610 1136 tempitem.misc6 = 0;
8611 1136 tempitem.misc7 = 0;
8612 1136 tempitem.misc8 = 0;
8613 1136 tempitem.misc9 = 0;
8614 1136 tempitem.misc10 = 0;
8615 1136 tempitem.wpn = 0;
8616 1136 tempitem.wpn2 = 0;
8617 1136 tempitem.wpn3 = 0;
8618 1136 tempitem.wpn4 = 0;
8619 1136 tempitem.wpn5 = 0;
8620 1136 tempitem.wpn6 = 0;
8621 1136 tempitem.wpn7 = 0;
8622 1136 tempitem.wpn8 = 0;
8623 1136 tempitem.wpn9 = 0;
8624 1136 tempitem.wpn10 = 0;
8625 1136 break;
8626 }
8627 case itype_rocs:
8628 {
8629 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8630 284 tempitem.misc1 = 0;
8631 284 tempitem.misc2 = 0;
8632 284 tempitem.misc3 = 0;
8633 284 tempitem.misc4 = 0;
8634 284 tempitem.misc5 = 0;
8635 284 tempitem.misc6 = 0;
8636 284 tempitem.misc7 = 0;
8637 284 tempitem.misc8 = 0;
8638 284 tempitem.misc9 = 0;
8639 284 tempitem.misc10 = 0;
8640 284 tempitem.wpn = 0;
8641 284 tempitem.wpn2 = 0;
8642 284 tempitem.wpn3 = 0;
8643 284 tempitem.wpn4 = 0;
8644 284 tempitem.wpn5 = 0;
8645 284 tempitem.wpn6 = 0;
8646 284 tempitem.wpn7 = 0;
8647 284 tempitem.wpn8 = 0;
8648 284 tempitem.wpn9 = 0;
8649 284 tempitem.wpn10 = 0;
8650 284 break;
8651 }
8652 case itype_hoverboots:
8653 {
8654 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8655 284 tempitem.misc2 = 0;
8656 284 tempitem.misc3 = 0;
8657 284 tempitem.misc4 = 0;
8658 284 tempitem.misc5 = 0;
8659 284 tempitem.misc6 = 0;
8660 284 tempitem.misc7 = 0;
8661 284 tempitem.misc8 = 0;
8662 284 tempitem.misc9 = 0;
8663 284 tempitem.misc10 = 0;
8664 284 tempitem.wpn2 = 0;
8665 284 tempitem.wpn3 = 0;
8666 284 tempitem.wpn4 = 0;
8667 284 tempitem.wpn5 = 0;
8668 284 tempitem.wpn6 = 0;
8669 284 tempitem.wpn7 = 0;
8670 284 tempitem.wpn8 = 0;
8671 284 tempitem.wpn9 = 0;
8672 284 tempitem.wpn10 = 0;
8673 284 break;
8674 }
8675 case itype_spinscroll:
8676 {
8677 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8678 284 tempitem.misc2 = 0;
8679 284 tempitem.misc3 = 0;
8680 284 tempitem.misc4 = 0;
8681 284 tempitem.misc5 = 0;
8682 284 tempitem.misc6 = 0;
8683 284 tempitem.misc7 = 0;
8684 284 tempitem.misc8 = 0;
8685 284 tempitem.misc9 = 0;
8686 284 tempitem.misc10 = 0;
8687 284 tempitem.wpn = 0;
8688 284 tempitem.wpn2 = 0;
8689 284 tempitem.wpn3 = 0;
8690 284 tempitem.wpn4 = 0;
8691 284 tempitem.wpn5 = 0;
8692 284 tempitem.wpn6 = 0;
8693 284 tempitem.wpn7 = 0;
8694 284 tempitem.wpn8 = 0;
8695 284 tempitem.wpn9 = 0;
8696 284 tempitem.wpn10 = 0;
8697 284 break;
8698 }
8699 case itype_crossscroll:
8700 {
8701 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8702 284 tempitem.misc1 = 0;
8703 284 tempitem.misc2 = 0;
8704 284 tempitem.misc3 = 0;
8705 284 tempitem.misc4 = 0;
8706 284 tempitem.misc5 = 0;
8707 284 tempitem.misc6 = 0;
8708 284 tempitem.misc7 = 0;
8709 284 tempitem.misc8 = 0;
8710 284 tempitem.misc9 = 0;
8711 284 tempitem.misc10 = 0;
8712 284 tempitem.wpn = 0;
8713 284 tempitem.wpn2 = 0;
8714 284 tempitem.wpn3 = 0;
8715 284 tempitem.wpn4 = 0;
8716 284 tempitem.wpn5 = 0;
8717 284 tempitem.wpn6 = 0;
8718 284 tempitem.wpn7 = 0;
8719 284 tempitem.wpn8 = 0;
8720 284 tempitem.wpn9 = 0;
8721 284 tempitem.wpn10 = 0;
8722 284 break;
8723 }
8724 case itype_quakescroll:
8725 {
8726 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8727 284 tempitem.misc3 = 0;
8728 284 tempitem.misc4 = 0;
8729 284 tempitem.misc5 = 0;
8730 284 tempitem.misc6 = 0;
8731 284 tempitem.misc7 = 0;
8732 284 tempitem.misc8 = 0;
8733 284 tempitem.misc9 = 0;
8734 284 tempitem.misc10 = 0;
8735 284 tempitem.wpn = 0;
8736 284 tempitem.wpn2 = 0;
8737 284 tempitem.wpn3 = 0;
8738 284 tempitem.wpn4 = 0;
8739 284 tempitem.wpn5 = 0;
8740 284 tempitem.wpn6 = 0;
8741 284 tempitem.wpn7 = 0;
8742 284 tempitem.wpn8 = 0;
8743 284 tempitem.wpn9 = 0;
8744 284 tempitem.wpn10 = 0;
8745 284 break;
8746 }
8747 case itype_whispring:
8748 {
8749 570 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8750 570 tempitem.misc2 = 0;
8751 570 tempitem.misc3 = 0;
8752 570 tempitem.misc4 = 0;
8753 570 tempitem.misc5 = 0;
8754 570 tempitem.misc6 = 0;
8755 570 tempitem.misc7 = 0;
8756 570 tempitem.misc8 = 0;
8757 570 tempitem.misc9 = 0;
8758 570 tempitem.misc10 = 0;
8759 570 tempitem.wpn = 0;
8760 570 tempitem.wpn2 = 0;
8761 570 tempitem.wpn3 = 0;
8762 570 tempitem.wpn4 = 0;
8763 570 tempitem.wpn5 = 0;
8764 570 tempitem.wpn6 = 0;
8765 570 tempitem.wpn7 = 0;
8766 570 tempitem.wpn8 = 0;
8767 570 tempitem.wpn9 = 0;
8768 570 tempitem.wpn10 = 0;
8769 570 break;
8770 }
8771 case itype_chargering:
8772 {
8773 568 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8774 568 tempitem.misc3 = 0;
8775 568 tempitem.misc4 = 0;
8776 568 tempitem.misc5 = 0;
8777 568 tempitem.misc6 = 0;
8778 568 tempitem.misc7 = 0;
8779 568 tempitem.misc8 = 0;
8780 568 tempitem.misc9 = 0;
8781 568 tempitem.misc10 = 0;
8782 568 tempitem.wpn = 0;
8783 568 tempitem.wpn2 = 0;
8784 568 tempitem.wpn3 = 0;
8785 568 tempitem.wpn4 = 0;
8786 568 tempitem.wpn5 = 0;
8787 568 tempitem.wpn6 = 0;
8788 568 tempitem.wpn7 = 0;
8789 568 tempitem.wpn8 = 0;
8790 568 tempitem.wpn9 = 0;
8791 568 tempitem.wpn10 = 0;
8792 568 break;
8793 }
8794 case itype_perilscroll:
8795 {
8796 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8797 284 tempitem.misc2 = 0;
8798 284 tempitem.misc3 = 0;
8799 284 tempitem.misc4 = 0;
8800 284 tempitem.misc5 = 0;
8801 284 tempitem.misc6 = 0;
8802 284 tempitem.misc7 = 0;
8803 284 tempitem.misc8 = 0;
8804 284 tempitem.misc9 = 0;
8805 284 tempitem.misc10 = 0;
8806 284 tempitem.wpn = 0;
8807 284 tempitem.wpn2 = 0;
8808 284 tempitem.wpn3 = 0;
8809 284 tempitem.wpn4 = 0;
8810 284 tempitem.wpn5 = 0;
8811 284 tempitem.wpn6 = 0;
8812 284 tempitem.wpn7 = 0;
8813 284 tempitem.wpn8 = 0;
8814 284 tempitem.wpn9 = 0;
8815 284 tempitem.wpn10 = 0;
8816 284 break;
8817 }
8818 case itype_wealthmedal:
8819 {
8820 854 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8821 854 tempitem.misc2 = 0;
8822 854 tempitem.misc3 = 0;
8823 854 tempitem.misc4 = 0;
8824 854 tempitem.misc5 = 0;
8825 854 tempitem.misc6 = 0;
8826 854 tempitem.misc7 = 0;
8827 854 tempitem.misc8 = 0;
8828 854 tempitem.misc9 = 0;
8829 854 tempitem.misc10 = 0;
8830 854 tempitem.wpn = 0;
8831 854 tempitem.wpn2 = 0;
8832 854 tempitem.wpn3 = 0;
8833 854 tempitem.wpn4 = 0;
8834 854 tempitem.wpn5 = 0;
8835 854 tempitem.wpn6 = 0;
8836 854 tempitem.wpn7 = 0;
8837 854 tempitem.wpn8 = 0;
8838 854 tempitem.wpn9 = 0;
8839 854 tempitem.wpn10 = 0;
8840 854 break;
8841 }
8842 case itype_heartring:
8843 {
8844 856 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8845 856 tempitem.misc3 = 0;
8846 856 tempitem.misc4 = 0;
8847 856 tempitem.misc5 = 0;
8848 856 tempitem.misc6 = 0;
8849 856 tempitem.misc7 = 0;
8850 856 tempitem.misc8 = 0;
8851 856 tempitem.misc9 = 0;
8852 856 tempitem.misc10 = 0;
8853 856 tempitem.wpn = 0;
8854 856 tempitem.wpn2 = 0;
8855 856 tempitem.wpn3 = 0;
8856 856 tempitem.wpn4 = 0;
8857 856 tempitem.wpn5 = 0;
8858 856 tempitem.wpn6 = 0;
8859 856 tempitem.wpn7 = 0;
8860 856 tempitem.wpn8 = 0;
8861 856 tempitem.wpn9 = 0;
8862 856 tempitem.wpn10 = 0;
8863 856 break;
8864 }
8865 case itype_magicring:
8866 {
8867 1144 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8868 1144 tempitem.misc3 = 0;
8869 1144 tempitem.misc4 = 0;
8870 1144 tempitem.misc5 = 0;
8871 1144 tempitem.misc6 = 0;
8872 1144 tempitem.misc7 = 0;
8873 1144 tempitem.misc8 = 0;
8874 1144 tempitem.misc9 = 0;
8875 1144 tempitem.misc10 = 0;
8876 1144 tempitem.wpn = 0;
8877 1144 tempitem.wpn2 = 0;
8878 1144 tempitem.wpn3 = 0;
8879 1144 tempitem.wpn4 = 0;
8880 1144 tempitem.wpn5 = 0;
8881 1144 tempitem.wpn6 = 0;
8882 1144 tempitem.wpn7 = 0;
8883 1144 tempitem.wpn8 = 0;
8884 1144 tempitem.wpn9 = 0;
8885 1144 tempitem.wpn10 = 0;
8886 1144 break;
8887 }
8888 case itype_spinscroll2:
8889 {
8890 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8891 284 tempitem.misc2 = 0;
8892 284 tempitem.misc3 = 0;
8893 284 tempitem.misc4 = 0;
8894 284 tempitem.misc5 = 0;
8895 284 tempitem.misc6 = 0;
8896 284 tempitem.misc7 = 0;
8897 284 tempitem.misc8 = 0;
8898 284 tempitem.misc9 = 0;
8899 284 tempitem.misc10 = 0;
8900 284 tempitem.wpn = 0;
8901 284 tempitem.wpn2 = 0;
8902 284 tempitem.wpn3 = 0;
8903 284 tempitem.wpn4 = 0;
8904 284 tempitem.wpn5 = 0;
8905 284 tempitem.wpn6 = 0;
8906 284 tempitem.wpn7 = 0;
8907 284 tempitem.wpn8 = 0;
8908 284 tempitem.wpn9 = 0;
8909 284 tempitem.wpn10 = 0;
8910 284 break;
8911 }
8912 case itype_quakescroll2:
8913 {
8914 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8915 284 tempitem.misc3 = 0;
8916 284 tempitem.misc4 = 0;
8917 284 tempitem.misc5 = 0;
8918 284 tempitem.misc6 = 0;
8919 284 tempitem.misc7 = 0;
8920 284 tempitem.misc8 = 0;
8921 284 tempitem.misc9 = 0;
8922 284 tempitem.misc10 = 0;
8923 284 tempitem.wpn = 0;
8924 284 tempitem.wpn2 = 0;
8925 284 tempitem.wpn3 = 0;
8926 284 tempitem.wpn4 = 0;
8927 284 tempitem.wpn5 = 0;
8928 284 tempitem.wpn6 = 0;
8929 284 tempitem.wpn7 = 0;
8930 284 tempitem.wpn8 = 0;
8931 284 tempitem.wpn9 = 0;
8932 284 tempitem.wpn10 = 0;
8933 284 break;
8934 }
8935 case itype_agony:
8936 {
8937 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8938 284 tempitem.misc2 = 0;
8939 284 tempitem.misc3 = 0;
8940 284 tempitem.misc4 = 0;
8941 284 tempitem.misc5 = 0;
8942 284 tempitem.misc6 = 0;
8943 284 tempitem.misc7 = 0;
8944 284 tempitem.misc8 = 0;
8945 284 tempitem.misc9 = 0;
8946 284 tempitem.misc10 = 0;
8947 284 tempitem.wpn = 0;
8948 284 tempitem.wpn2 = 0;
8949 284 tempitem.wpn3 = 0;
8950 284 tempitem.wpn4 = 0;
8951 284 tempitem.wpn5 = 0;
8952 284 tempitem.wpn6 = 0;
8953 284 tempitem.wpn7 = 0;
8954 284 tempitem.wpn8 = 0;
8955 284 tempitem.wpn9 = 0;
8956 284 tempitem.wpn10 = 0;
8957 284 break;
8958 }
8959 case itype_stompboots:
8960 {
8961 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8962 284 tempitem.misc1 = 0;
8963 284 tempitem.misc2 = 0;
8964 284 tempitem.misc3 = 0;
8965 284 tempitem.misc4 = 0;
8966 284 tempitem.misc5 = 0;
8967 284 tempitem.misc6 = 0;
8968 284 tempitem.misc7 = 0;
8969 284 tempitem.misc8 = 0;
8970 284 tempitem.misc9 = 0;
8971 284 tempitem.misc10 = 0;
8972 284 tempitem.wpn = 0;
8973 284 tempitem.wpn2 = 0;
8974 284 tempitem.wpn3 = 0;
8975 284 tempitem.wpn4 = 0;
8976 284 tempitem.wpn5 = 0;
8977 284 tempitem.wpn6 = 0;
8978 284 tempitem.wpn7 = 0;
8979 284 tempitem.wpn8 = 0;
8980 284 tempitem.wpn9 = 0;
8981 284 tempitem.wpn10 = 0;
8982 284 break;
8983 }
8984 case itype_whimsicalring:
8985 {
8986 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8987 284 tempitem.misc2 = 0;
8988 284 tempitem.misc3 = 0;
8989 284 tempitem.misc4 = 0;
8990 284 tempitem.misc5 = 0;
8991 284 tempitem.misc6 = 0;
8992 284 tempitem.misc7 = 0;
8993 284 tempitem.misc8 = 0;
8994 284 tempitem.misc9 = 0;
8995 284 tempitem.misc10 = 0;
8996 284 tempitem.wpn = 0;
8997 284 tempitem.wpn2 = 0;
8998 284 tempitem.wpn3 = 0;
8999 284 tempitem.wpn4 = 0;
9000 284 tempitem.wpn5 = 0;
9001 284 tempitem.wpn6 = 0;
9002 284 tempitem.wpn7 = 0;
9003 284 tempitem.wpn8 = 0;
9004 284 tempitem.wpn9 = 0;
9005 284 tempitem.wpn10 = 0;
9006 284 break;
9007 }
9008 case itype_perilring:
9009 {
9010 310 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9011 310 tempitem.misc2 = 0;
9012 310 tempitem.misc3 = 0;
9013 310 tempitem.misc4 = 0;
9014 310 tempitem.misc5 = 0;
9015 310 tempitem.misc6 = 0;
9016 310 tempitem.misc7 = 0;
9017 310 tempitem.misc8 = 0;
9018 310 tempitem.misc9 = 0;
9019 310 tempitem.misc10 = 0;
9020 310 tempitem.wpn = 0;
9021 310 tempitem.wpn2 = 0;
9022 310 tempitem.wpn3 = 0;
9023 310 tempitem.wpn4 = 0;
9024 310 tempitem.wpn5 = 0;
9025 310 tempitem.wpn6 = 0;
9026 310 tempitem.wpn7 = 0;
9027 310 tempitem.wpn8 = 0;
9028 310 tempitem.wpn9 = 0;
9029 310 tempitem.wpn10 = 0;
9030 310 break;
9031 }
9032 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9033 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9034 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9035 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9036 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9037 {
9038 10813 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9039 10813 tempitem.misc1 = 0;
9040 10813 tempitem.misc2 = 0;
9041 10813 tempitem.misc3 = 0;
9042 10813 tempitem.misc4 = 0;
9043 10813 tempitem.misc5 = 0;
9044 10813 tempitem.misc6 = 0;
9045 10813 tempitem.misc7 = 0;
9046 10813 tempitem.misc8 = 0;
9047 10813 tempitem.misc9 = 0;
9048 10813 tempitem.misc10 = 0;
9049 10813 tempitem.wpn = 0;
9050 10813 tempitem.wpn2 = 0;
9051 10813 tempitem.wpn3 = 0;
9052 10813 tempitem.wpn4 = 0;
9053 10813 tempitem.wpn5 = 0;
9054 10813 tempitem.wpn6 = 0;
9055 10813 tempitem.wpn7 = 0;
9056 10813 tempitem.wpn8 = 0;
9057 10813 tempitem.wpn9 = 0;
9058 10813 tempitem.wpn10 = 0;
9059 10813 break;
9060 }
9061 }
9062 73216 }
9063 //Port quest rules to items
9064
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if( s_version <= 31)
9065 {
9066
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 72916 times.
73216 if(tempitem.family == itype_bomb)
9067 {
9068
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 144 times.
300 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9069 144 else tempitem.flags &= ~ item_flag2;
9070 300 }
9071
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 72630 times.
72916 else if(tempitem.family == itype_sbomb)
9072 {
9073
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 128 times.
286 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9074 128 else tempitem.flags &= ~ item_flag2;
9075 286 }
9076
9077
2/2
✓ Branch 0 taken 858 times.
✓ Branch 1 taken 71772 times.
72630 else if(tempitem.family == itype_brang)
9078 {
9079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
858 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9080 858 else tempitem.flags &= ~ item_flag4;
9081 858 }
9082
2/2
✓ Branch 0 taken 71470 times.
✓ Branch 1 taken 302 times.
71772 else if(tempitem.family == itype_wand)
9083 {
9084
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 278 times.
302 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9085 278 else tempitem.flags &= ~ item_flag3;
9086 302 }
9087 73216 }
9088
9089 //Port quest rules to items
9090
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if( s_version <= 37)
9091 {
9092
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 72930 times.
73216 if(tempitem.family == itype_flippers)
9093 {
9094
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 207 times.
286 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9095 207 else tempitem.flags &= ~ item_flag1;
9096 286 }
9097
2/2
✓ Branch 0 taken 55242 times.
✓ Branch 1 taken 17688 times.
72930 else if(tempitem.family == itype_sword)
9098 {
9099
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 17226 times.
17688 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9100 17226 else tempitem.flags &= ~ item_flag5;
9101 17688 }
9102
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 54940 times.
55242 else if(tempitem.family == itype_wand)
9103 {
9104
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 292 times.
302 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9105 292 else tempitem.flags &= ~ item_flag5;
9106 302 }
9107
4/4
✓ Branch 0 taken 54640 times.
✓ Branch 1 taken 300 times.
✓ Branch 2 taken 610 times.
✓ Branch 3 taken 54030 times.
54940 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9108 {
9109 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9110
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 529 times.
910 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9111 529 else tempitem.flags &= ~ item_flag3;
9112 910 }
9113 73216 }
9114
9115
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if( s_version < 38)
9116 {
9117
4/4
✓ Branch 0 taken 72358 times.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 570 times.
✓ Branch 3 taken 71788 times.
73216 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9118 {
9119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1428 times.
1428 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9120 1428 else tempitem.flags &= ~item_flag4;
9121
9122
2/2
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 726 times.
1428 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9123 726 else tempitem.flags &= ~(item_flag5|item_flag6);
9124 1428 }
9125
2/2
✓ Branch 0 taken 70944 times.
✓ Branch 1 taken 844 times.
71788 else if(tempitem.family == itype_arrow)
9126 {
9127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 844 times.
844 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9128 844 else tempitem.flags &= ~item_flag4;
9129
9130
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 432 times.
844 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9131 432 else tempitem.flags |= item_flag2;
9132 844 }
9133 73216 }
9134
9135
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if( s_version < 39)
9136 {
9137
6/6
✓ Branch 0 taken 72932 times.
✓ Branch 1 taken 284 times.
✓ Branch 2 taken 72632 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 610 times.
✓ Branch 5 taken 72022 times.
73216 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9138 {
9139
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1178 times.
1194 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9140 1178 else tempitem.flags &= ~item_flag5;
9141 1194 }
9142
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 71399 times.
72022 else if(tempitem.family == itype_potion)
9143 {
9144
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 461 times.
623 if(get_qr(qr_NONBUBBLEMEDICINE))
9145 {
9146 162 tempitem.flags &= ~(item_flag3|item_flag4);
9147 162 }
9148 else
9149 {
9150 461 tempitem.flags |= item_flag3;
9151
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 331 times.
461 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9152 331 else tempitem.flags &= ~item_flag4;
9153 }
9154 623 }
9155
2/2
✓ Branch 0 taken 70831 times.
✓ Branch 1 taken 568 times.
71399 else if(tempitem.family == itype_triforcepiece)
9156 {
9157
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 484 times.
568 if(get_qr(qr_NONBUBBLETRIFORCE))
9158 {
9159 84 tempitem.flags |= item_flag3;
9160
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9161 28 else tempitem.flags &= ~item_flag4;
9162 84 }
9163 else
9164 {
9165 484 tempitem.flags &= ~(item_flag3|item_flag4);
9166 }
9167 568 }
9168 73216 }
9169
9170
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if( s_version < 40)
9171 {
9172
4/4
✓ Branch 0 taken 72310 times.
✓ Branch 1 taken 906 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 72000 times.
73216 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9173 {
9174
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 930 times.
1216 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9175 930 else tempitem.flags &= ~item_flag1;
9176 1216 }
9177
8/8
✓ Branch 0 taken 71390 times.
✓ Branch 1 taken 610 times.
✓ Branch 2 taken 53702 times.
✓ Branch 3 taken 17688 times.
✓ Branch 4 taken 53400 times.
✓ Branch 5 taken 302 times.
✓ Branch 6 taken 284 times.
✓ Branch 7 taken 53116 times.
72000 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9178 {
9179
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18776 times.
18884 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9180 18776 else tempitem.flags &= ~item_flag8;
9181 18884 }
9182
6/6
✓ Branch 0 taken 55528 times.
✓ Branch 1 taken 17688 times.
✓ Branch 2 taken 55226 times.
✓ Branch 3 taken 302 times.
✓ Branch 4 taken 286 times.
✓ Branch 5 taken 54940 times.
73216 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9183 {
9184
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 18172 times.
18276 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9185 18172 else tempitem.flags &= ~item_flag7;
9186 18276 }
9187
2/2
✓ Branch 0 taken 54656 times.
✓ Branch 1 taken 284 times.
54940 else if(tempitem.family == itype_cbyrna)
9188 {
9189 284 tempitem.flags |= item_flag7;
9190 284 }
9191 73216 }
9192
9193
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if( s_version < 41 )
9194 {
9195
2/2
✓ Branch 0 taken 55528 times.
✓ Branch 1 taken 17688 times.
73216 if(tempitem.family == itype_sword)
9196 {
9197
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 17404 times.
17688 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9198 17404 else tempitem.flags &= ~item_flag9;
9199
9200
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17260 times.
17688 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9201 17260 else tempitem.flags &= ~item_flag10;
9202 17688 }
9203 73216 }
9204
9205
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if( s_version < 42 )
9206 {
9207
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 72914 times.
73216 if(tempitem.family == itype_wand)
9208 {
9209
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 278 times.
302 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9210 278 else tempitem.flags &= ~item_flag3;
9211
9212 302 tempitem.flags &= ~item_flag6;
9213 302 }
9214
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 72628 times.
72914 else if(tempitem.family == itype_hammer)
9215 {
9216 286 tempitem.flags &= ~item_flag3;
9217 286 }
9218
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 72344 times.
72628 else if(tempitem.family == itype_cbyrna)
9219 {
9220 284 tempitem.flags |= item_flag3;
9221
9222 284 tempitem.flags &= ~item_flag6;
9223 284 }
9224
2/2
✓ Branch 0 taken 54656 times.
✓ Branch 1 taken 17688 times.
72344 else if(tempitem.family == itype_sword)
9225 {
9226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17688 times.
17688 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9227 17688 else tempitem.flags &= ~item_flag6;
9228 17688 }
9229 73216 }
9230
9231
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if( s_version < 43 )
9232 {
9233
2/2
✓ Branch 0 taken 72884 times.
✓ Branch 1 taken 332 times.
73216 if(tempitem.family == itype_whistle)
9234 {
9235
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 320 times.
332 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9236 320 else tempitem.flags &= ~item_flag3;
9237 332 }
9238 73216 }
9239
9240
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if( s_version < 45 )
9241 {
9242
2/2
✓ Branch 0 taken 72930 times.
✓ Branch 1 taken 286 times.
73216 if(tempitem.family == itype_flippers)
9243 {
9244 286 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9245 286 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9246 286 }
9247 73216 }
9248
9249
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if( s_version < 46 )
9250 {
9251
2/2
✓ Branch 0 taken 72932 times.
✓ Branch 1 taken 284 times.
73216 if(tempitem.family == itype_raft)
9252 {
9253 284 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9254 284 }
9255 73216 }
9256
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if ( s_version < 34 ) //! set the default counter for older quests.
9257 {
9258
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 73101 times.
73216 if ( (tempitem.flags & item_rupee_magic) )
9259 {
9260 115 tempitem.cost_counter[0] = 1;
9261 115 }
9262 else
9263 {
9264
2/2
✓ Branch 0 taken 43776 times.
✓ Branch 1 taken 29325 times.
73101 if(get_qr(qr_ENABLEMAGIC))
9265 43776 tempitem.cost_counter[0] = 4;
9266 else
9267 {
9268 29325 tempitem.cost_amount[0] = 0;
9269 29325 tempitem.cost_counter[0] = -1;
9270 }
9271 }
9272 73216 }
9273
9274
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if ( s_version < 35 ) //new Lens of Truth flags
9275 {
9276
2/2
✓ Branch 0 taken 72956 times.
✓ Branch 1 taken 260 times.
73216 if ( tempitem.family == itype_lens )
9277 {
9278
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 12 times.
260 if ( get_qr(qr_RAFTLENS) )
9279 {
9280 12 tempitem.flags |= item_flag4;
9281 12 }
9282
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 167 times.
260 if ( get_qr(qr_LENSHINTS) )
9283 {
9284 167 tempitem.flags |= item_flag1;
9285 167 }
9286
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 16 times.
260 if ( get_qr(qr_LENSSEESENEMIES) )
9287 {
9288 16 tempitem.flags |= item_flag5;
9289 16 }
9290 260 }
9291 73216 }
9292
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9293 {
9294
2/2
✓ Branch 0 taken 585728 times.
✓ Branch 1 taken 73216 times.
658944 for ( int32_t q = 0; q < 8; q++ )
9295 {
9296 585728 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9297 585728 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9298 585728 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9299 585728 tempitem.sprite_initiald[q] = 0;
9300 585728 }
9301 73216 tempitem.sprite_script = 0;
9302 73216 }
9303
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9304 {
9305 73216 tempitem.pickupflag = 0;
9306 73216 }
9307
9308
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if( s_version < 51 )
9309 {
9310
2/2
✓ Branch 0 taken 72606 times.
✓ Branch 1 taken 610 times.
73216 if( tempitem.family == itype_candle )
9311 {
9312 610 tempitem.misc4 = 50; //Step speed
9313 610 }
9314 73216 }
9315
9316
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if( s_version < 52 )
9317 {
9318
2/2
✓ Branch 0 taken 72350 times.
✓ Branch 1 taken 866 times.
73216 if( tempitem.family == itype_shield )
9319 866 tempitem.flags |= item_flag1; //'Block Front' flag
9320 73216 }
9321
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 73216 times.
119296 if(s_version < 53)
9322 {
9323
4/4
✓ Branch 0 taken 71786 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 300 times.
✓ Branch 3 taken 286 times.
73216 switch(tempitem.family)
9324 {
9325 case itype_arrow:
9326 844 tempitem.cost_counter[1] = crARROWS;
9327 844 tempitem.cost_amount[1] = 1;
9328 844 break;
9329 case itype_bomb:
9330 300 tempitem.cost_counter[1] = crBOMBS;
9331 300 tempitem.cost_amount[1] = 1;
9332 300 break;
9333 case itype_sbomb:
9334 286 tempitem.cost_counter[1] = crSBOMBS;
9335 286 tempitem.cost_amount[1] = 1;
9336 286 break;
9337 default:
9338 71786 tempitem.cost_counter[1] = crNONE;
9339 71786 tempitem.cost_amount[1] = 0;
9340 71786 }
9341 73216 tempitem.magiccosttimer[1] = 0;
9342 73216 }
9343
2/2
✓ Branch 0 taken 43264 times.
✓ Branch 1 taken 76032 times.
119296 if( s_version < 54 )
9344 {
9345
2/2
✓ Branch 0 taken 75733 times.
✓ Branch 1 taken 299 times.
76032 if( tempitem.family == itype_flippers )
9346 299 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9347 76032 }
9348
2/2
✓ Branch 0 taken 43264 times.
✓ Branch 1 taken 76032 times.
119296 if(s_version < 55)
9349 {
9350
3/3
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 590 times.
✓ Branch 2 taken 74852 times.
76032 switch(tempitem.family)
9351 {
9352 case itype_spinscroll:
9353 case itype_quakescroll:
9354 590 tempitem.usesound2 = WAV_ZN1CHARGE;
9355 590 break;
9356 case itype_spinscroll2:
9357 case itype_quakescroll2:
9358 590 tempitem.usesound2 = WAV_ZN1CHARGE2;
9359 590 break;
9360 }
9361 76032 }
9362
2/2
✓ Branch 0 taken 43264 times.
✓ Branch 1 taken 76032 times.
119296 if(s_version < 56)
9363 {
9364
4/4
✓ Branch 0 taken 74790 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 311 times.
76032 switch(tempitem.family)
9365 {
9366 case itype_divinefire:
9367
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 11 times.
295 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9368
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 213 times.
295 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9369 295 tempitem.flags |= item_flag11; //Divine Fire
9370 295 break;
9371 case itype_candle:
9372
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 319 times.
636 SETFLAG(tempitem.flags, item_flag9, tempitem.fam_type > 1); //Strong Fire
9373 636 tempitem.flags &= ~item_flag10; //Magic Fire
9374 636 tempitem.flags &= ~item_flag11; //Divine Fire
9375 636 break;
9376 case itype_book:
9377 311 tempitem.flags |= item_flag9; //Strong Fire
9378 311 tempitem.flags |= item_flag10; //Magic Fire
9379 311 tempitem.flags &= ~item_flag11; //Divine Fire
9380 311 break;
9381 }
9382 76032 }
9383
9384
2/2
✓ Branch 0 taken 108308 times.
✓ Branch 1 taken 10988 times.
119296 if(tempitem.fam_type==0) // Always do this
9385 10988 tempitem.fam_type=1;
9386
9387 119296 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9388 119296 }
9389
9390 466 return 0;
9391 467 }
9392
9393 static bool did_init_def_items = false;
9394 238458 void init_def_items()
9395 {
9396
2/2
✓ Branch 0 taken 238100 times.
✓ Branch 1 taken 358 times.
238458 if(did_init_def_items) return;
9397 358 did_init_def_items = true;
9398 358 default_items[3].cost_counter[1] = crBOMBS;
9399 358 default_items[13].cost_counter[1] = crARROWS;
9400 358 default_items[14].cost_counter[1] = crARROWS;
9401 358 default_items[48].cost_counter[1] = crSBOMBS;
9402 358 default_items[57].cost_counter[1] = crARROWS;
9403 238458 }
9404 238458 void reset_itembuf(itemdata *item, int32_t id)
9405 {
9406 238458 init_def_items();
9407
2/2
✓ Branch 0 taken 100005 times.
✓ Branch 1 taken 138453 times.
238458 if(id<iLast)
9408 {
9409 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9410 138453 word tile = item->tile;
9411 138453 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9412 138453 int32_t ltm = item->ltm;
9413
9414 138453 memcpy(item,&default_items[id],sizeof(itemdata));
9415 138453 item->tile = tile;
9416 138453 item->misc_flags = miscs;
9417 138453 item->csets = cset;
9418 138453 item->frames = frames;
9419 138453 item->speed = speed;
9420 138453 item->delay = delay;
9421 138453 item->ltm = ltm;
9422 138453 }
9423 238458 }
9424
9425 98816 void reset_itemname(int32_t id)
9426 {
9427 98816 sprintf(item_string[id],"zz%03d",id);
9428
9429
2/2
✓ Branch 0 taken 43618 times.
✓ Branch 1 taken 55198 times.
98816 if(id < iLast)
9430 55198 strcpy(item_string[id],old_item_string[id]);
9431 98816 }
9432
9433 467 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9434 {
9435
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 24 times.
467 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9436
9437 467 word weapons_to_read=MAXWPNS;
9438 int32_t dummy;
9439 byte padding;
9440 wpndata tempweapon;
9441 467 word s_version=0;
9442
9443
9444
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 6 times.
467 if(Header->zelda_version < 0x186)
9445 {
9446 6 weapons_to_read=64;
9447 6 }
9448
9449
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 6 times.
467 if(Header->zelda_version < 0x185)
9450 {
9451 6 weapons_to_read=32;
9452 6 }
9453
9454
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 443 times.
467 if(Header->zelda_version > 0x192)
9455 {
9456 443 weapons_to_read=0;
9457
9458 //section version info
9459
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&s_version,f))
9460 {
9461 return qe_invalid;
9462 }
9463
9464 443 FFCore.quest_format[vWeaponSprites] = s_version;
9465
9466
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!read_deprecated_section_cversion(f))
9467 {
9468 return qe_invalid;
9469 }
9470
9471 //section size
9472
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetl(&dummy,f))
9473 {
9474 return qe_invalid;
9475 }
9476
9477 //finally... section data
9478
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&weapons_to_read,f))
9479 {
9480 return qe_invalid;
9481 }
9482
9483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if (weapons_to_read > MAXWPNS)
9484 {
9485 return qe_invalid;
9486 }
9487 443 }
9488
9489
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 83 times.
467 if(s_version>2)
9490 {
9491
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 384 times.
98688 for(int32_t i=0; i<weapons_to_read; i++)
9492 {
9493 char tempname[64];
9494
9495
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if(!pfread(tempname, 64, f))
9496 {
9497 return qe_invalid;
9498 }
9499
9500 98304 weapon_string[i][0] = '\0';
9501 98304 strncat(weapon_string[i], tempname, 64 - 1);
9502 98304 }
9503
9504
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(s_version<4)
9505 {
9506 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9507 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9508 }
9509
9510
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(s_version<5)
9511 {
9512 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9513 }
9514
9515 /*
9516 if (s_version<6)
9517 {
9518 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9519 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9520 }
9521 */
9522 384 }
9523
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9524 {
9525
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9526 20992 reset_weaponname(i);
9527 82 }
9528
9529
2/2
✓ Branch 0 taken 107116 times.
✓ Branch 1 taken 467 times.
107583 for(int32_t i=0; i<weapons_to_read; i++)
9530 {
9531 107116 word oldtile = 0;
9532
2/2
✓ Branch 0 taken 44800 times.
✓ Branch 1 taken 62316 times.
107116 if (s_version < 8)
9533 {
9534
1/2
✓ Branch 0 taken 62316 times.
✗ Branch 1 not taken.
62316 if (!p_igetw(&oldtile, f))
9535 return qe_invalid;
9536 62316 }
9537
9538
1/2
✓ Branch 0 taken 107116 times.
✗ Branch 1 not taken.
107116 if(!p_getc(&tempweapon.misc,f))
9539 {
9540 return qe_invalid;
9541 }
9542
9543
1/2
✓ Branch 0 taken 107116 times.
✗ Branch 1 not taken.
107116 if(!p_getc(&tempweapon.csets,f))
9544 {
9545 return qe_invalid;
9546 }
9547
9548
1/2
✓ Branch 0 taken 107116 times.
✗ Branch 1 not taken.
107116 if(!p_getc(&tempweapon.frames,f))
9549 {
9550 return qe_invalid;
9551 }
9552
9553
1/2
✓ Branch 0 taken 107116 times.
✗ Branch 1 not taken.
107116 if(!p_getc(&tempweapon.speed,f))
9554 {
9555 return qe_invalid;
9556 }
9557
9558
1/2
✓ Branch 0 taken 107116 times.
✗ Branch 1 not taken.
107116 if(!p_getc(&tempweapon.type,f))
9559 {
9560 return qe_invalid;
9561 }
9562
9563
2/2
✓ Branch 0 taken 61036 times.
✓ Branch 1 taken 46080 times.
107116 if ( s_version >= 7 )
9564 {
9565
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetw(&tempweapon.script,f))
9566 {
9567 return qe_invalid;
9568 }
9569
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if(!p_igetl(&tempweapon.tile,f))
9570 {
9571 return qe_invalid;
9572 }
9573 46080 }
9574
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 61036 times.
107116 if ( s_version < 7 )
9575 {
9576 61036 tempweapon.tile = oldtile;
9577 61036 }
9578
9579
2/2
✓ Branch 0 taken 102316 times.
✓ Branch 1 taken 4800 times.
107116 if(Header->zelda_version < 0x193)
9580 {
9581
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9582 {
9583 return qe_invalid;
9584 }
9585 4800 }
9586
9587
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 8812 times.
107116 if(s_version < 6)
9588 {
9589
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9590 {
9591 18 tempweapon.misc |= WF_BEHIND;
9592 18 }
9593 else
9594 8794 tempweapon.misc &= ~WF_BEHIND;
9595 8812 }
9596
9597
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 106860 times.
107116 if (!should_skip)
9598 106860 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9599 107116 }
9600
9601
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 466 times.
467 if (should_skip)
9602 1 return 0;
9603
9604
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<2)
9605 {
9606 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9607 82 }
9608
9609
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(s_version<5)
9610 {
9611 82 wpnsbuf[iwQuarterHearts].tile=1;
9612 82 wpnsbuf[iwQuarterHearts].csets=1;
9613 82 }
9614
9615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if(Header->zelda_version < 0x176)
9616 {
9617 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9618 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9619 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9620 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9621 }
9622
9623
3/4
✓ Branch 0 taken 448 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
471 if((Header->zelda_version < 0x192)||
9624
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 443 times.
448 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9625 {
9626 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9627 18 }
9628
9629
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 443 times.
466 if((Header->zelda_version < 0x210))
9630 {
9631 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9632 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9633 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9634 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9635 23 }
9636
9637 466 return 0;
9638 467 }
9639
9640 220614 static void guy_update_firesfx(guydata& tempguy)
9641 {
9642 220614 tempguy.firesfx = 0;
9643
2/2
✓ Branch 0 taken 6340 times.
✓ Branch 1 taken 214274 times.
220614 if (tempguy.family == eeWIZZ)
9644 {
9645
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 961 times.
✓ Branch 2 taken 3874 times.
✓ Branch 3 taken 816 times.
✓ Branch 4 taken 689 times.
6340 switch (tempguy.attributes[1])
9646 {
9647 case 0: // normal weapon
9648 3874 tempguy.firesfx = WAV_WAND;
9649 3874 break;
9650 case 1: // 8 shots
9651
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 734 times.
816 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) tempguy.firesfx = WAV_FIRE;
9652 else
9653 {
9654
3/8
✓ Branch 0 taken 631 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
734 switch (tempguy.weapon)
9655 {
9656 case ewFireTrail:
9657 case ewFlame:
9658 case ewFlame2Trail:
9659 case ewFlame2:
9660 631 tempguy.firesfx = WAV_FIRE;
9661 631 break;
9662 case ewWind:
9663 case ewMagic:
9664 87 tempguy.firesfx = WAV_WAND;
9665 87 break;
9666 case ewIce:
9667 tempguy.firesfx = WAV_ZN1ICE;
9668 break;
9669 case ewRock:
9670 tempguy.firesfx = WAV_ZN1ROCK;
9671 break;
9672 case ewFireball2:
9673 case ewFireball:
9674 16 tempguy.firesfx = WAV_ZN1FIREBALL;
9675 16 break;
9676 case ewBrang:
9677 tempguy.firesfx = WAV_BRANG;
9678 break;
9679 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9680 tempguy.firesfx = WAV_BOMB;
9681 break;
9682 default:
9683 tempguy.firesfx = 0;
9684 break;
9685 }
9686 734 break;
9687 }
9688 case 2: // Summon
9689 1043 tempguy.firesfx = WAV_FIRE;
9690 1043 break;
9691 case 3: // Summon Layer
9692 689 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9693 689 break;
9694 }
9695 6340 }
9696 else
9697 {
9698
6/6
✓ Branch 0 taken 162366 times.
✓ Branch 1 taken 51908 times.
✓ Branch 2 taken 41260 times.
✓ Branch 3 taken 203626 times.
✓ Branch 4 taken 46586 times.
✓ Branch 5 taken 46582 times.
214274 if ((tempguy.family == eeWALK || tempguy.family == eePROJECTILE) && (tempguy.attributes[0] == e1tSUMMON || tempguy.attributes[0] == e1tSUMMONLAYER))
9699 {
9700 93168 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9701 93168 }
9702 else
9703 {
9704
7/8
✓ Branch 0 taken 9463 times.
✓ Branch 1 taken 2319 times.
✓ Branch 2 taken 1764 times.
✓ Branch 3 taken 12624 times.
✓ Branch 4 taken 171328 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3895 times.
✓ Branch 7 taken 2233 times.
203626 switch (tempguy.weapon)
9705 {
9706 case ewFireTrail:
9707 case ewFlame:
9708 case ewFlame2Trail:
9709 case ewFlame2:
9710 9463 tempguy.firesfx = WAV_FIRE;
9711 9463 break;
9712 case ewWind:
9713 case ewMagic:
9714 1764 tempguy.firesfx = WAV_WAND;
9715 1764 break;
9716 case ewIce:
9717 tempguy.firesfx = WAV_ZN1ICE;
9718 break;
9719 case ewRock:
9720 3895 tempguy.firesfx = WAV_ZN1ROCK;
9721 3895 break;
9722 case ewFireball2:
9723 case ewFireball:
9724 12624 tempguy.firesfx = WAV_ZN1FIREBALL;
9725 12624 break;
9726 case ewBrang:
9727 2233 tempguy.firesfx = WAV_BRANG;
9728 2233 break;
9729 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9730 2319 tempguy.firesfx = WAV_BOMB;
9731 2319 break;
9732 default:
9733 171328 tempguy.firesfx = 0;
9734 171328 break;
9735 }
9736 }
9737 }
9738 209970 }
9739
9740 209970 static void guy_update_weaponflags(guydata& tempguy)
9741 {
9742 209970 tempguy.wunblockable = 0;
9743 209970 tempguy.wmoveflags = move_none;
9744
4/4
✓ Branch 0 taken 203550 times.
✓ Branch 1 taken 6420 times.
✓ Branch 2 taken 2958 times.
✓ Branch 3 taken 200592 times.
209970 if (tempguy.weapon == ewFlame || tempguy.weapon == ewFireTrail)
9745 9378 tempguy.wmoveflags |= (move_obeys_grav | move_can_pitfall);
9746 209970 tempguy.weapoverrideFLAGS = 0;
9747 209970 tempguy.weap_hxofs = 0;
9748 209970 tempguy.weap_hyofs = 0;
9749 209970 tempguy.weap_hxsz = 0;
9750 209970 tempguy.weap_hysz = 0;
9751 209970 tempguy.weap_hzsz = 0;
9752 209970 tempguy.weap_xofs = 0;
9753 209970 tempguy.weap_yofs = 0;
9754 209970 tempguy.weap_tilew = 0;
9755 209970 tempguy.weap_tileh = 0;
9756
5/5
✓ Branch 0 taken 2467 times.
✓ Branch 1 taken 169385 times.
✓ Branch 2 taken 18217 times.
✓ Branch 3 taken 12640 times.
✓ Branch 4 taken 7261 times.
209970 switch (tempguy.weapon)
9757 {
9758 case ewFireball: case ewFireball2:
9759 12640 tempguy.wstep = 175;
9760 12640 break;
9761 case ewSword: case ewLitBomb: case ewLitSBomb:
9762 case ewRock: case ewMagic: case ewWind:
9763 18217 tempguy.wstep = 300;
9764 18217 break;
9765 case ewArrow:
9766 2467 tempguy.wstep = 200;
9767 2467 break;
9768 case ewFlame: case ewFlame2:
9769 7261 tempguy.wstep = 100;
9770 7261 break;
9771 default:
9772 169385 tempguy.wstep = 0;
9773 169385 break;
9774 }
9775
2/2
✓ Branch 0 taken 1049850 times.
✓ Branch 1 taken 209970 times.
1259820 for (int q = 0; q < WPNSPR_MAX; ++q)
9776 {
9777 1049850 tempguy.burnsprs[q] = 0;
9778 1049850 tempguy.light_rads[q] = 0;
9779 1049850 }
9780 209970 }
9781
9782 209970 static void guy_update_weaponspecialsfx(guydata& tempguy)
9783 {
9784
3/3
✓ Branch 0 taken 2233 times.
✓ Branch 1 taken 205363 times.
✓ Branch 2 taken 2374 times.
209970 switch (tempguy.weapon)
9785 {
9786 case ewBrang:
9787 2233 tempguy.specialsfx = WAV_BRANG;
9788 2233 break;
9789 case ewBomb: case ewSBomb: case ewLitBomb:case ewLitSBomb:
9790 2374 tempguy.specialsfx = WAV_BOMB;
9791 2374 break;
9792 default:
9793 205363 tempguy.specialsfx = 0;
9794 205363 break;
9795 }
9796 209970 }
9797
9798 466 void init_guys(int32_t guyversion)
9799 {
9800
2/2
✓ Branch 0 taken 238592 times.
✓ Branch 1 taken 466 times.
239058 for(int32_t i=0; i<MAXGUYS; i++)
9801 {
9802 238592 guysbuf[i] = default_guys[0];
9803 238592 }
9804
9805
2/2
✓ Branch 0 taken 82482 times.
✓ Branch 1 taken 466 times.
82948 for(int32_t i=0; i<OLDMAXGUYS; i++)
9806 {
9807 82482 guysbuf[i] = default_guys[i];
9808
2/2
✓ Branch 0 taken 81550 times.
✓ Branch 1 taken 932 times.
82482 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
9809 82482 guysbuf[i].spr_death = iwDeath;
9810 82482 guysbuf[i].spr_spawn = iwSpawn;
9811 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9812
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 67968 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
82482 if(guyversion<=3 && i==ePATRABS)
9813 {
9814 82 guysbuf[i].bosspal=spDIG;
9815 82 guysbuf[i].cset=14;
9816 82 guysbuf[i].attributes[8] = 14;
9817 82 }
9818
9819
2/2
✓ Branch 0 taken 67968 times.
✓ Branch 1 taken 14514 times.
82482 if(guyversion<=3)
9820 {
9821 // Rope/Ghini Flash rules
9822
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9823 {
9824
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
9825 {
9826 59 guysbuf[i].flags &= ~guy_flashing;
9827 59 }
9828 10443 }
9829
9830
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9831 {
9832
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9833 {
9834 72 guysbuf[i].flags &= ~guy_flashing;
9835 72 }
9836 2124 }
9837
9838
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
9839 {
9840
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9841 {
9842 4 guysbuf[i].flags |= guy_blinking;
9843 4 }
9844
9845
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9846 {
9847 38 guysbuf[i].flags |= guy_transparent;
9848 38 }
9849 82 }
9850
9851
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
9852 {
9853 164 guysbuf[i].flags |= guy_ignore_kill_all;
9854 164 }
9855 14514 }
9856
9857 // Darknut fix
9858
10/10
✓ Branch 0 taken 82016 times.
✓ Branch 1 taken 466 times.
✓ Branch 2 taken 81550 times.
✓ Branch 3 taken 466 times.
✓ Branch 4 taken 81084 times.
✓ Branch 5 taken 466 times.
✓ Branch 6 taken 80618 times.
✓ Branch 7 taken 466 times.
✓ Branch 8 taken 466 times.
✓ Branch 9 taken 80152 times.
82482 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9859 {
9860
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 405 times.
2330 if(get_qr(qr_NEWENEMYTILES))
9861 {
9862 1925 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9863 1925 guysbuf[i].s_width=guysbuf[i].e_width;
9864 1925 guysbuf[i].s_height=guysbuf[i].e_height;
9865 1925 }
9866 405 else guysbuf[i].s_tile=860;
9867
9868
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2010 times.
2330 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9869 2010 guysbuf[i].flags &= ~guy_bkshield;
9870 else
9871 320 guysbuf[i].flags |= guy_bkshield;
9872 2330 }
9873
9874
4/4
✓ Branch 0 taken 82016 times.
✓ Branch 1 taken 466 times.
✓ Branch 2 taken 82432 times.
✓ Branch 3 taken 50 times.
82482 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9875 {
9876 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
9877 50 }
9878
9879 82482 guy_update_firesfx(guysbuf[i]);
9880 82482 guy_update_weaponflags(guysbuf[i]);
9881 82482 guy_update_weaponspecialsfx(guysbuf[i]);
9882 82482 }
9883 466 }
9884
9885 20992 void reset_weaponname(int32_t i)
9886 {
9887
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
9888 {
9889 7216 strcpy(weapon_string[i],old_weapon_string[i]);
9890 7216 }
9891 else
9892 13776 sprintf(weapon_string[i],"zz%03d",i);
9893 20992 }
9894
9895 466 void init_item_drop_sets()
9896 {
9897
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9898 {
9899 // item_drop_sets[i] = default_item_drop_sets[0];
9900 119296 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9901 119296 }
9902
9903
2/2
✓ Branch 0 taken 6058 times.
✓ Branch 1 taken 466 times.
6524 for(int32_t i=0; i<isMAX; i++)
9904 {
9905 6058 item_drop_sets[i] = default_item_drop_sets[i];
9906
9907 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9908
2/2
✓ Branch 0 taken 60580 times.
✓ Branch 1 taken 6058 times.
66638 for(int32_t j=0; j<10; ++j)
9909 {
9910 60580 int32_t it = item_drop_sets[i].item[j];
9911
9912
3/4
✓ Branch 0 taken 42688 times.
✓ Branch 1 taken 17892 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2754 times.
60580 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9913
2/2
✓ Branch 0 taken 2754 times.
✓ Branch 1 taken 39934 times.
42688 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9914 {
9915 2754 item_drop_sets[i].chance[j+1]=0;
9916 2754 }
9917
4/4
✓ Branch 0 taken 1864 times.
✓ Branch 1 taken 55962 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 1720 times.
57826 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9918 {
9919 144 item_drop_sets[i].chance[j+1]=0;
9920 144 }
9921
9922 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9923
2/2
✓ Branch 0 taken 60556 times.
✓ Branch 1 taken 24 times.
60580 if(itemsbuf[it].family == itype_misc)
9924 {
9925 // If a non-gameplay item was selected, then item drop was aborted.
9926 // Reflect this by increasing the 'Nothing' chance accordingly.
9927 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9928 24 item_drop_sets[i].chance[j+1]=0;
9929 24 }
9930 60580 }
9931 6058 }
9932 466 }
9933
9934 466 void init_favorites()
9935 {
9936
2/2
✓ Branch 0 taken 587160 times.
✓ Branch 1 taken 466 times.
587626 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9937 {
9938 587160 favorite_combos[i]=-1;
9939 587160 }
9940 466 }
9941
9942 const char *ctype_name[cMAX]=
9943 {
9944 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9945 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9946 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9947 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9948 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9949 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9950 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9951 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9952 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9953 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9954 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9955 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9956 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9957 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9958 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9959 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9960 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9961 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9962 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9963 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9964 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9965 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9966 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9967 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9968 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9969 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9970 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9971 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9972
9973 };
9974
9975 757 int32_t init_combo_classes()
9976 {
9977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
757 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9978
2/2
✓ Branch 0 taken 138531 times.
✓ Branch 1 taken 757 times.
139288 for(int32_t i=0; i<cMAX; i++)
9979 {
9980 138531 combo_class_buf[i] = default_combo_classes[i];
9981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138531 times.
138531 if ( char const* nm = zi->getComboTypeName(i) )
9982 {
9983 138531 size_t len = strlen(nm);
9984
2/2
✓ Branch 0 taken 8865984 times.
✓ Branch 1 taken 138531 times.
9004515 for ( size_t q = 0; q < 64; q++ )
9985 {
9986
2/2
✓ Branch 0 taken 2029517 times.
✓ Branch 1 taken 6836467 times.
8865984 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9987 8865984 }
9988 138531 }
9989 138531 }
9990
9991 757 return 0;
9992 }
9993
9994 309 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites)
9995 {
9996
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 263 times.
309 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
9997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309 times.
309 if (should_skip) return 0;
9998
9999
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 assert(v_herosprites < 6);
10000
10001 309 zinit.hero_swim_speed=67; //default
10002 309 setupherotiles(zinit.heroAnimationStyle);
10003 309 setupherodefenses();
10004 309 setupherooffsets();
10005
10006
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 204 times.
309 if(v_herosprites>=0)
10007 {
10008 word tile, tile2;
10009 byte flip, extend, dummy_byte;
10010
10011
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int32_t i=0; i<4; i++)
10012 {
10013
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetw(&tile,f))
10014 {
10015 return qe_invalid;
10016 }
10017
10018
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&flip,f))
10019 {
10020 return qe_invalid;
10021 }
10022
10023
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&extend,f))
10024 {
10025 return qe_invalid;
10026 }
10027
10028 816 walkspr[i][spr_tile]=(int32_t)tile;
10029 816 walkspr[i][spr_flip]=(int32_t)flip;
10030 816 walkspr[i][spr_extend]=(int32_t)extend;
10031 816 }
10032
10033
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int32_t i=0; i<4; i++)
10034 {
10035
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetw(&tile,f))
10036 {
10037 return qe_invalid;
10038 }
10039
10040
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&flip,f))
10041 {
10042 return qe_invalid;
10043 }
10044
10045
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&extend,f))
10046 {
10047 return qe_invalid;
10048 }
10049
10050 816 stabspr[i][spr_tile]=(int32_t)tile;
10051 816 stabspr[i][spr_flip]=(int32_t)flip;
10052 816 stabspr[i][spr_extend]=(int32_t)extend;
10053 816 }
10054
10055
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int32_t i=0; i<4; i++)
10056 {
10057
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetw(&tile,f))
10058 {
10059 return qe_invalid;
10060 }
10061
10062
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&flip,f))
10063 {
10064 return qe_invalid;
10065 }
10066
10067
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&extend,f))
10068 {
10069 return qe_invalid;
10070 }
10071
10072 816 slashspr[i][spr_tile]=(int32_t)tile;
10073 816 slashspr[i][spr_flip]=(int32_t)flip;
10074 816 slashspr[i][spr_extend]=(int32_t)extend;
10075 816 }
10076
10077
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int32_t i=0; i<4; i++)
10078 {
10079
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetw(&tile,f))
10080 {
10081 return qe_invalid;
10082 }
10083
10084
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&flip,f))
10085 {
10086 return qe_invalid;
10087 }
10088
10089
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&extend,f))
10090 {
10091 return qe_invalid;
10092 }
10093
10094 816 floatspr[i][spr_tile]=(int32_t)tile;
10095 816 floatspr[i][spr_flip]=(int32_t)flip;
10096 816 floatspr[i][spr_extend]=(int32_t)extend;
10097 816 }
10098
10099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if(v_herosprites>1)
10100 {
10101
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int32_t i=0; i<4; i++)
10102 {
10103
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetw(&tile,f))
10104 {
10105 return qe_invalid;
10106 }
10107
10108
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&flip,f))
10109 {
10110 return qe_invalid;
10111 }
10112
10113
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&extend,f))
10114 {
10115 return qe_invalid;
10116 }
10117
10118 816 swimspr[i][spr_tile]=(int32_t)tile;
10119 816 swimspr[i][spr_flip]=(int32_t)flip;
10120 816 swimspr[i][spr_extend]=(int32_t)extend;
10121 816 }
10122 204 }
10123
10124
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int32_t i=0; i<4; i++)
10125 {
10126
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetw(&tile,f))
10127 {
10128 return qe_invalid;
10129 }
10130
10131
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&flip,f))
10132 {
10133 return qe_invalid;
10134 }
10135
10136
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&extend,f))
10137 {
10138 return qe_invalid;
10139 }
10140
10141 816 divespr[i][spr_tile]=(int32_t)tile;
10142 816 divespr[i][spr_flip]=(int32_t)flip;
10143 816 divespr[i][spr_extend]=(int32_t)extend;
10144 816 }
10145
10146
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int32_t i=0; i<4; i++)
10147 {
10148
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetw(&tile,f))
10149 {
10150 return qe_invalid;
10151 }
10152
10153
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&flip,f))
10154 {
10155 return qe_invalid;
10156 }
10157
10158
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&extend,f))
10159 {
10160 return qe_invalid;
10161 }
10162
10163 816 poundspr[i][spr_tile]=(int32_t)tile;
10164 816 poundspr[i][spr_flip]=(int32_t)flip;
10165 816 poundspr[i][spr_extend]=(int32_t)extend;
10166 816 }
10167
10168
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_igetw(&tile,f))
10169 {
10170 return qe_invalid;
10171 }
10172
10173 204 flip=0;
10174
10175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if(v_herosprites>0)
10176 {
10177
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_getc(&flip,f))
10178 {
10179 return qe_invalid;
10180 }
10181 204 }
10182
10183
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_getc(&extend,f))
10184 {
10185 return qe_invalid;
10186 }
10187
10188 204 castingspr[spr_tile]=(int32_t)tile;
10189 204 castingspr[spr_flip]=(int32_t)flip;
10190 204 castingspr[spr_extend]=(int32_t)extend;
10191
10192
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(v_herosprites>0)
10193 {
10194 204 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10195
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 204 times.
612 for(int32_t i=0; i<2; i++)
10196 {
10197
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 408 times.
1224 for(int32_t j=0; j<num_holdsprs; j++)
10198 {
10199
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetw(&tile,f))
10200 {
10201 return qe_invalid;
10202 }
10203
10204
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&flip,f))
10205 {
10206 return qe_invalid;
10207 }
10208
10209
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&extend,f))
10210 {
10211 return qe_invalid;
10212 }
10213
10214 816 holdspr[i][j][spr_tile]=(int32_t)tile;
10215 816 holdspr[i][j][spr_flip]=(int32_t)flip;
10216 816 holdspr[i][j][spr_extend]=(int32_t)extend;
10217 816 }
10218 408 }
10219 204 }
10220 else
10221 {
10222 for(int32_t i=0; i<2; i++)
10223 {
10224 if(!p_igetw(&tile,f))
10225 {
10226 return qe_invalid;
10227 }
10228
10229 if(!p_igetw(&tile2,f))
10230 {
10231 return qe_invalid;
10232 }
10233
10234 if(!p_getc(&extend,f))
10235 {
10236 return qe_invalid;
10237 }
10238
10239 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10240 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10241 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10242 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10243 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10244 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10245 }
10246 }
10247
10248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if(v_herosprites>2)
10249 {
10250
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int32_t i=0; i<4; i++)
10251 {
10252
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetw(&tile,f))
10253 {
10254 return qe_invalid;
10255 }
10256
10257
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&flip,f))
10258 {
10259 return qe_invalid;
10260 }
10261
10262
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&extend,f))
10263 {
10264 return qe_invalid;
10265 }
10266
10267 816 jumpspr[i][spr_tile]=(int32_t)tile;
10268 816 jumpspr[i][spr_flip]=(int32_t)flip;
10269 816 jumpspr[i][spr_extend]=(int32_t)extend;
10270 816 }
10271 204 }
10272
10273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if(v_herosprites>3)
10274 {
10275
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int32_t i=0; i<4; i++)
10276 {
10277
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_igetw(&tile,f))
10278 {
10279 return qe_invalid;
10280 }
10281
10282
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if(!p_getc(&flip,f))
10283 {
10284 return qe_invalid;
10285 }
10286
10287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 816 times.
816 if(!p_getc(&extend,f))
10288 {
10289 return qe_invalid;
10290 }
10291
10292 816 chargespr[i][spr_tile]=(int32_t)tile;
10293 816 chargespr[i][spr_flip]=(int32_t)flip;
10294 816 chargespr[i][spr_extend]=(int32_t)extend;
10295 816 }
10296 204 }
10297
10298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if(v_herosprites>4)
10299 {
10300
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_getc(&dummy_byte,f))
10301 {
10302 return qe_invalid;
10303 }
10304
10305 204 zinit.hero_swim_speed=(byte)dummy_byte;
10306 204 }
10307
10308 204 memset(frozenspr, 0, sizeof(frozenspr));
10309 204 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10310 204 memset(onfirespr, 0, sizeof(onfirespr));
10311 204 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10312 204 memset(diggingspr, 0, sizeof(diggingspr));
10313 204 memset(usingrodspr, 0, sizeof(usingrodspr));
10314 204 memset(usingcanespr, 0, sizeof(usingcanespr));
10315 204 memset(pushingspr, 0, sizeof(pushingspr));
10316 204 memset(liftingspr, 0, sizeof(liftingspr));
10317 204 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10318 204 memset(stunnedspr, 0, sizeof(stunnedspr));
10319 204 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10320 204 memset(fallingspr, 0, sizeof(fallingspr));
10321 204 memset(shockedspr, 0, sizeof(shockedspr));
10322 204 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10323 204 memset(pullswordspr, 0, sizeof(pullswordspr));
10324 204 memset(readingspr, 0, sizeof(readingspr));
10325 204 memset(slash180spr, 0, sizeof(slash180spr));
10326 204 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10327 204 memset(dashspr, 0, sizeof(dashspr));
10328 204 memset(bonkspr, 0, sizeof(bonkspr));
10329 204 memset(medallionsprs, 0, sizeof(medallionsprs));
10330 204 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10331 204 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10332
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int32_t q = 0; q < 4; ++q)
10333 {
10334
2/2
✓ Branch 0 taken 2448 times.
✓ Branch 1 taken 816 times.
3264 for(int32_t p = 0; p < 3; ++p)
10335 {
10336 2448 drowningspr[q][p] = divespr[q][p];
10337 2448 drowning_lavaspr[q][p] = divespr[q][p];
10338 2448 }
10339 816 }
10340 204 memset(sideswimspr, 0, sizeof(sideswimspr));
10341 204 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10342 204 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10343 204 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10344 204 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10345 204 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10346 204 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10347 204 }
10348
10349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309 times.
309 if(FFCore.quest_format[vInitData] < 34)
10350 {
10351 309 bool fastswim = zinit.hero_swim_speed > 60;
10352 // '2/3' or '1/2'
10353 309 zinit.hero_swim_mult = fastswim ? 2 : 1;
10354 309 zinit.hero_swim_div = fastswim ? 3 : 2;
10355 309 }
10356 309 return 0;
10357 309 }
10358
10359 30600 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10360 {
10361 30600 arr[spr_tile] = tile;
10362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30600 times.
30600 arr[spr_flip] = (flip > 3 ? 0 : flip);
10363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30600 times.
30600 arr[spr_extend] = (ext > 2 ? 0 : ext);
10364 30600 }
10365 //Used to read the player sprites as int32_t, not word.
10366 180 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites)
10367 {
10368 180 zinit.hero_swim_speed=67; //default
10369 180 setupherotiles(zinit.heroAnimationStyle);
10370 180 setupherodefenses();
10371 180 setupherooffsets();
10372
10373 int32_t tile, tile2;
10374 byte flip, extend, dummy_byte;
10375
10376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(v_herosprites>=0)
10377 {
10378
10379
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t i=0; i<4; i++)
10380 {
10381
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10382 {
10383 return qe_invalid;
10384 }
10385
10386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10387 {
10388 return qe_invalid;
10389 }
10390
10391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10392 {
10393 return qe_invalid;
10394 }
10395
10396 720 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10397 720 }
10398
10399
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t i=0; i<4; i++)
10400 {
10401
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10402 {
10403 return qe_invalid;
10404 }
10405
10406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10407 {
10408 return qe_invalid;
10409 }
10410
10411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10412 {
10413 return qe_invalid;
10414 }
10415
10416 720 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10417 720 }
10418
10419
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t i=0; i<4; i++)
10420 {
10421
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10422 {
10423 return qe_invalid;
10424 }
10425
10426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10427 {
10428 return qe_invalid;
10429 }
10430
10431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10432 {
10433 return qe_invalid;
10434 }
10435
10436 720 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10437 720 }
10438
10439
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t i=0; i<4; i++)
10440 {
10441
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10442 {
10443 return qe_invalid;
10444 }
10445
10446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10447 {
10448 return qe_invalid;
10449 }
10450
10451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10452 {
10453 return qe_invalid;
10454 }
10455
10456 720 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10457 720 }
10458
10459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(v_herosprites>1)
10460 {
10461
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t i=0; i<4; i++)
10462 {
10463
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10464 {
10465 return qe_invalid;
10466 }
10467
10468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10469 {
10470 return qe_invalid;
10471 }
10472
10473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10474 {
10475 return qe_invalid;
10476 }
10477
10478 720 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10479 720 }
10480 180 }
10481
10482
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t i=0; i<4; i++)
10483 {
10484
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10485 {
10486 return qe_invalid;
10487 }
10488
10489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10490 {
10491 return qe_invalid;
10492 }
10493
10494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10495 {
10496 return qe_invalid;
10497 }
10498
10499 720 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10500 720 }
10501
10502
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t i=0; i<4; i++)
10503 {
10504
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10505 {
10506 return qe_invalid;
10507 }
10508
10509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10510 {
10511 return qe_invalid;
10512 }
10513
10514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10515 {
10516 return qe_invalid;
10517 }
10518
10519 720 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10520 720 }
10521
10522
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_igetl(&tile,f))
10523 {
10524 return qe_invalid;
10525 }
10526
10527 180 flip=0;
10528
10529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(v_herosprites>0)
10530 {
10531
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_getc(&flip,f))
10532 {
10533 return qe_invalid;
10534 }
10535 180 }
10536
10537
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_getc(&extend,f))
10538 {
10539 return qe_invalid;
10540 }
10541
10542 180 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10543
10544
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(v_herosprites>0)
10545 {
10546 180 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10547
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 180 times.
540 for(int32_t i=0; i<2; i++)
10548 {
10549
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t j=0; j<num_holdsprs; j++)
10550 {
10551
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(!p_igetl(&tile,f))
10552 {
10553 return qe_invalid;
10554 }
10555
10556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1080 times.
1080 if(!p_getc(&flip,f))
10557 {
10558 return qe_invalid;
10559 }
10560
10561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1080 times.
1080 if(!p_getc(&extend,f))
10562 {
10563 return qe_invalid;
10564 }
10565
10566 1080 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10567 1080 }
10568 360 }
10569 180 }
10570 else
10571 {
10572 for(int32_t i=0; i<2; i++)
10573 {
10574 if(!p_igetl(&tile,f))
10575 {
10576 return qe_invalid;
10577 }
10578
10579 if(!p_igetl(&tile2,f))
10580 {
10581 return qe_invalid;
10582 }
10583
10584 if(!p_getc(&extend,f))
10585 {
10586 return qe_invalid;
10587 }
10588
10589 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10590 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10591 }
10592 }
10593
10594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(v_herosprites>2)
10595 {
10596
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t i=0; i<4; i++)
10597 {
10598
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10599 {
10600 return qe_invalid;
10601 }
10602
10603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10604 {
10605 return qe_invalid;
10606 }
10607
10608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10609 {
10610 return qe_invalid;
10611 }
10612
10613 720 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10614 720 }
10615 180 }
10616
10617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(v_herosprites>3)
10618 {
10619
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t i=0; i<4; i++)
10620 {
10621
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10622 {
10623 return qe_invalid;
10624 }
10625
10626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10627 {
10628 return qe_invalid;
10629 }
10630
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10632 {
10633 return qe_invalid;
10634 }
10635
10636 720 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10637 720 }
10638 180 }
10639
10640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(v_herosprites>4)
10641 {
10642
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_getc(&dummy_byte,f))
10643 {
10644 return qe_invalid;
10645 }
10646
10647 180 zinit.hero_swim_speed=(byte)dummy_byte;
10648 180 }
10649
10650
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(v_herosprites>6)
10651 {
10652
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10653 {
10654
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10655 return qe_invalid;
10656
10657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10658 return qe_invalid;
10659
10660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10661 return qe_invalid;
10662
10663 720 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10664 720 }
10665
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10666 {
10667
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10668 return qe_invalid;
10669
10670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10671 return qe_invalid;
10672
10673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10674 return qe_invalid;
10675
10676 720 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10677 720 }
10678
10679
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10680 {
10681
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10682 return qe_invalid;
10683
10684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10685 return qe_invalid;
10686
10687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10688 return qe_invalid;
10689
10690 720 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10691 720 }
10692
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10693 {
10694
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10695 return qe_invalid;
10696
10697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10698 return qe_invalid;
10699
10700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10701 return qe_invalid;
10702
10703 720 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10704 720 }
10705
10706
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10707 {
10708
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10709 return qe_invalid;
10710
10711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10712 return qe_invalid;
10713
10714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10715 return qe_invalid;
10716
10717 720 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10718 720 }
10719
10720
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10721 {
10722
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10723 return qe_invalid;
10724
10725
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10726 return qe_invalid;
10727
10728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10729 return qe_invalid;
10730
10731 720 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10732 720 }
10733
10734
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10735 {
10736
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10737 return qe_invalid;
10738
10739
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10740 return qe_invalid;
10741
10742
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&extend,f))
10743 return qe_invalid;
10744
10745 720 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10746 720 }
10747
10748
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10749 {
10750
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10751 return qe_invalid;
10752
10753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10754 return qe_invalid;
10755
10756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10757 return qe_invalid;
10758
10759 720 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10760 720 }
10761
10762
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10763 {
10764
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10765 return qe_invalid;
10766
10767
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10768 return qe_invalid;
10769
10770
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&extend,f))
10771 return qe_invalid;
10772
10773 720 byte frames = 0;
10774
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 700 times.
720 if(v_herosprites > 15)
10775 {
10776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 700 times.
700 if(!p_getc(&frames,f))
10777 return qe_invalid;
10778 700 }
10779
10780 720 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10781 720 liftingspr[q][spr_frames] = frames;
10782 720 }
10783
10784
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10785 {
10786
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10787 return qe_invalid;
10788
10789
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10790 return qe_invalid;
10791
10792
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&extend,f))
10793 return qe_invalid;
10794
10795 720 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10796 720 }
10797
10798
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10799 {
10800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_igetl(&tile,f))
10801 return qe_invalid;
10802
10803
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10804 return qe_invalid;
10805
10806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10807 return qe_invalid;
10808
10809 720 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10810 720 }
10811
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10812 {
10813
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10814 return qe_invalid;
10815
10816
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10817 return qe_invalid;
10818
10819
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&extend,f))
10820 return qe_invalid;
10821
10822 720 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10823 720 }
10824
10825
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10826 {
10827
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10828 return qe_invalid;
10829
10830
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10831 return qe_invalid;
10832
10833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10834 return qe_invalid;
10835
10836 720 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10837 720 }
10838
10839
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10840 {
10841
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10842 return qe_invalid;
10843
10844
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10845 return qe_invalid;
10846
10847
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&extend,f))
10848 return qe_invalid;
10849
10850 720 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10851 720 }
10852
10853
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10854 {
10855
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10856 return qe_invalid;
10857
10858
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10859 return qe_invalid;
10860
10861
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&extend,f))
10862 return qe_invalid;
10863
10864 720 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10865 720 }
10866
10867
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10868 {
10869
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10870 return qe_invalid;
10871
10872
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10873 return qe_invalid;
10874
10875
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&extend,f))
10876 return qe_invalid;
10877
10878 720 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10879 720 }
10880
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10881 {
10882
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10883 return qe_invalid;
10884
10885
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10886 return qe_invalid;
10887
10888
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&extend,f))
10889 return qe_invalid;
10890
10891 720 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10892 720 }
10893
10894
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10895 {
10896
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10897 return qe_invalid;
10898
10899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
10900 return qe_invalid;
10901
10902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10903 return qe_invalid;
10904
10905 720 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10906 720 }
10907
10908
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10909 {
10910
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10911 return qe_invalid;
10912
10913
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10914 return qe_invalid;
10915
10916
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&extend,f))
10917 return qe_invalid;
10918
10919 720 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10920 720 }
10921
10922
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10923 {
10924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_igetl(&tile,f))
10925 return qe_invalid;
10926
10927
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10928 return qe_invalid;
10929
10930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
10931 return qe_invalid;
10932
10933 720 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10934 720 }
10935
10936
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10937 {
10938
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10939 return qe_invalid;
10940
10941
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10942 return qe_invalid;
10943
10944
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&extend,f))
10945 return qe_invalid;
10946
10947 720 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10948 720 }
10949
10950
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10951 {
10952
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10953 return qe_invalid;
10954
10955
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10956 return qe_invalid;
10957
10958
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&extend,f))
10959 return qe_invalid;
10960
10961 720 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10962 720 }
10963
10964
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
10965 {
10966
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
10967 return qe_invalid;
10968
10969
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&flip,f))
10970 return qe_invalid;
10971
10972
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_getc(&extend,f))
10973 return qe_invalid;
10974
10975 720 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10976 720 }
10977
10978
2/2
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 180 times.
720 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10979 {
10980
1/2
✓ Branch 0 taken 540 times.
✗ Branch 1 not taken.
540 if(!p_igetl(&tile,f))
10981 return qe_invalid;
10982
10983
1/2
✓ Branch 0 taken 540 times.
✗ Branch 1 not taken.
540 if(!p_getc(&flip,f))
10984 return qe_invalid;
10985
10986
1/2
✓ Branch 0 taken 540 times.
✗ Branch 1 not taken.
540 if(!p_getc(&extend,f))
10987 return qe_invalid;
10988
10989 540 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10990 540 }
10991 180 }
10992 else
10993 {
10994 memset(frozenspr, 0, sizeof(frozenspr));
10995 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10996 memset(onfirespr, 0, sizeof(onfirespr));
10997 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10998 memset(diggingspr, 0, sizeof(diggingspr));
10999 memset(usingrodspr, 0, sizeof(usingrodspr));
11000 memset(usingcanespr, 0, sizeof(usingcanespr));
11001 memset(pushingspr, 0, sizeof(pushingspr));
11002 memset(liftingspr, 0, sizeof(liftingspr));
11003 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11004 memset(stunnedspr, 0, sizeof(stunnedspr));
11005 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11006 memset(fallingspr, 0, sizeof(fallingspr));
11007 memset(shockedspr, 0, sizeof(shockedspr));
11008 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11009 memset(pullswordspr, 0, sizeof(pullswordspr));
11010 memset(readingspr, 0, sizeof(readingspr));
11011 memset(slash180spr, 0, sizeof(slash180spr));
11012 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11013 memset(dashspr, 0, sizeof(dashspr));
11014 memset(bonkspr, 0, sizeof(bonkspr));
11015 memset(medallionsprs, 0, sizeof(medallionsprs));
11016 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11017 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11018 for(int32_t q = 0; q < 4; ++q)
11019 {
11020 for(int32_t p = 0; p < 3; ++p)
11021 {
11022 drowningspr[q][p] = divespr[q][p];
11023 drowning_lavaspr[q][p] = divespr[q][p];
11024 }
11025 }
11026 }
11027
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if (v_herosprites > 8)
11028 {
11029
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
11030 {
11031
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
11032 return qe_invalid;
11033
11034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
11035 return qe_invalid;
11036
11037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
11038 return qe_invalid;
11039
11040 720 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11041 720 }
11042 180 }
11043 else
11044 {
11045 memset(sideswimspr, 0, sizeof(sideswimspr));
11046 }
11047
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if (v_herosprites > 9)
11048 {
11049
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
11050 {
11051
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
11052 return qe_invalid;
11053
11054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
11055 return qe_invalid;
11056
11057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
11058 return qe_invalid;
11059
11060 720 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11061 720 }
11062
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
11063 {
11064
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
11065 return qe_invalid;
11066
11067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
11068 return qe_invalid;
11069
11070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
11071 return qe_invalid;
11072
11073 720 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11074 720 }
11075
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
11076 {
11077
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
11078 return qe_invalid;
11079
11080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
11081 return qe_invalid;
11082
11083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
11084 return qe_invalid;
11085
11086 720 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11087 720 }
11088
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
11089 {
11090
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
11091 return qe_invalid;
11092
11093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
11094 return qe_invalid;
11095
11096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
11097 return qe_invalid;
11098
11099 720 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11100 720 }
11101 180 }
11102 else
11103 {
11104 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11105 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11106 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11107 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11108 }
11109
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if (v_herosprites > 10)
11110 {
11111
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
11112 {
11113 int32_t hmr;
11114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_igetl(&hmr,f))
11115 return qe_invalid;
11116
11117 720 hammeroffsets[q] = hmr;
11118 720 }
11119 180 }
11120 else
11121 {
11122 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11123 }
11124
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if (v_herosprites > 11)
11125 {
11126
2/2
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 180 times.
720 for(int32_t q = 0; q < 3; ++q)
11127 {
11128
1/2
✓ Branch 0 taken 540 times.
✗ Branch 1 not taken.
540 if(!p_igetl(&tile,f))
11129 return qe_invalid;
11130
11131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 540 times.
540 if(!p_getc(&flip,f))
11132 return qe_invalid;
11133
11134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 540 times.
540 if(!p_getc(&extend,f))
11135 return qe_invalid;
11136
11137 540 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11138 540 }
11139 180 }
11140 else
11141 {
11142 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11143 }
11144
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if (v_herosprites > 12)
11145 {
11146
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_igetl(&tile,f))
11147 return qe_invalid;
11148
11149
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_getc(&flip,f))
11150 return qe_invalid;
11151
11152
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_getc(&extend,f))
11153 return qe_invalid;
11154 180 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11155
11156 180 }
11157 else
11158 {
11159 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11160 }
11161
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if (v_herosprites > 13)
11162 {
11163
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
11164 {
11165
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
11166 return qe_invalid;
11167
11168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
11169 return qe_invalid;
11170
11171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
11172 return qe_invalid;
11173
11174 720 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11175 720 }
11176 180 }
11177 else
11178 {
11179 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11180 }
11181
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if (v_herosprites > 14)
11182 {
11183
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
900 for(int32_t q = 0; q < 4; ++q)
11184 {
11185
1/2
✓ Branch 0 taken 720 times.
✗ Branch 1 not taken.
720 if(!p_igetl(&tile,f))
11186 return qe_invalid;
11187
11188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&flip,f))
11189 return qe_invalid;
11190
11191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
720 if(!p_getc(&extend,f))
11192 return qe_invalid;
11193
11194 720 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11195 720 }
11196 180 }
11197 else
11198 {
11199 memset(revslashspr, 0, sizeof(revslashspr));
11200 }
11201
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if (v_herosprites > 7)
11202 {
11203 180 int32_t num_defense = wMax;
11204 180 byte def = 0;
11205
11206 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11207 /*if(v_herosprites > [x])
11208 * {
11209 * num_defense = 146 //value of wMax on version 8
11210 * }
11211 */
11212
11213
2/2
✓ Branch 0 taken 26280 times.
✓ Branch 1 taken 180 times.
26460 for (int32_t q = 0; q < num_defense; q++)
11214 {
11215
1/2
✓ Branch 0 taken 26280 times.
✗ Branch 1 not taken.
26280 if (!p_getc(&def, f))
11216 return qe_invalid;
11217
11218 26280 hero_defence[q] = def;
11219 26280 }
11220 180 }
11221 else
11222 {
11223 int32_t num_defense = wMax;
11224 for (int32_t q = 0; q < num_defense; q++)
11225 {
11226 hero_defence[q] = 0;
11227 }
11228 }
11229 180 }
11230
11231
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 11 times.
180 if(FFCore.quest_format[vInitData] < 34)
11232 {
11233 11 bool fastswim = zinit.hero_swim_speed > 60;
11234 // '2/3' or '1/2'
11235 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11236 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11237 11 }
11238 180 return 0;
11239 180 }
11240
11241
11242 384 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11243 {
11244 //these are here to bypass compiler warnings about unused arguments
11245 384 Header=Header;
11246
11247 dword dummy;
11248 384 word s_version=0;
11249
11250 //section version info
11251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_igetw(&s_version,f))
11252 {
11253 return qe_invalid;
11254 }
11255
11256 384 FFCore.quest_format[vHeroSprites] = s_version;
11257
11258
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
11259 {
11260 return qe_invalid;
11261 }
11262
11263 //section size
11264
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&dummy,f))
11265 {
11266 return qe_invalid;
11267 }
11268
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 204 times.
384 if ( s_version >= 6 )
11269 {
11270 180 return readherosprites3(f, s_version);
11271 }
11272 204 else return readherosprites2(f, s_version);
11273 384 }
11274
11275 221 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11276 {
11277 221 subscreens_active.clear();
11278 221 subscreens_passive.clear();
11279 221 subscreens_overlay.clear();
11280
2/2
✓ Branch 0 taken 28288 times.
✓ Branch 1 taken 221 times.
28509 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11281 {
11282 subscreen_group g;
11283 28288 memset(&g,0,sizeof(subscreen_group));
11284 28288 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28288 times.
28288 if(ret!=0)
11286 return ret;
11287
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 27130 times.
28288 if(g.objects[0].type == ssoNULL) continue;
11288
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 675 times.
1158 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11289 1158 ZCSubscreen& sub = vec.emplace_back();
11290 1158 sub.load_old(g);
11291 1158 }
11292
11293 221 return 0;
11294 221 }
11295
11296 28288 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11297 {
11298 28288 int32_t numsub=0;
11299 28288 byte temp_ss=0;
11300 subscreen_object temp_sub_stack;
11301 28288 subscreen_object *temp_sub = &temp_sub_stack;
11302
11303 char tempname[64];
11304
11305 // FWIW I never saw anything bigger than 20.
11306 #define MAX_DP1_LEN 1024
11307 char tempdp1[MAX_DP1_LEN];
11308
11309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28288 times.
28288 if(!pfread(tempname,64,f))
11310 {
11311 return qe_invalid;
11312 }
11313
11314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28288 times.
28288 if(s_version > 1)
11315 {
11316
1/2
✓ Branch 0 taken 28288 times.
✗ Branch 1 not taken.
28288 if(!p_getc(&temp_ss,f))
11317 {
11318 return qe_invalid;
11319 }
11320 28288 }
11321
11322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28288 times.
28288 if(s_version < 4)
11323 {
11324 uint8_t tmp=0;
11325
11326 if(!p_getc(&tmp,f))
11327 {
11328 return qe_invalid;
11329 }
11330
11331 numsub = (int32_t)tmp;
11332 }
11333 else
11334 {
11335 word tmp;
11336
11337
1/2
✓ Branch 0 taken 28288 times.
✗ Branch 1 not taken.
28288 if(!p_igetw(&tmp, f))
11338 {
11339 return qe_invalid;
11340 }
11341
11342 28288 numsub = (int32_t)tmp;
11343 }
11344
11345 int32_t j;
11346
11347
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75010 times.
✓ Branch 2 taken 46722 times.
✓ Branch 3 taken 28288 times.
75010 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11348 {
11349 46722 memset(temp_sub,0,sizeof(subscreen_object));
11350
11351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46722 times.
46722 switch(g->objects[j].type)
11352 {
11353 case ssoTEXT:
11354 case ssoTEXTBOX:
11355 case ssoCURRENTITEMTEXT:
11356 case ssoCURRENTITEMCLASSTEXT:
11357 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11358
11359 //fall through
11360 default:
11361 46722 memset(&g->objects[j],0,sizeof(subscreen_object));
11362 46722 break;
11363 }
11364
11365
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_getc(&(temp_sub->type),f))
11366 return qe_invalid;
11367
11368
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_getc(&(temp_sub->pos),f))
11369 return qe_invalid;
11370
11371
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(s_version < 5)
11372 {
11373 switch(temp_sub->pos)
11374 {
11375 case 0:
11376 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11377 break;
11378
11379 case 1:
11380 temp_sub->pos = sspUP;
11381 break;
11382
11383 case 2:
11384 temp_sub->pos = sspDOWN;
11385 break;
11386
11387 default:
11388 temp_sub->pos = 0;
11389 }
11390 }
11391
11392
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetw(&(temp_sub->x),f))
11393 return qe_invalid;
11394
11395
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetw(&(temp_sub->y),f))
11396 return qe_invalid;
11397
11398
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetw(&(temp_sub->w),f))
11399 return qe_invalid;
11400
11401
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetw(&(temp_sub->h),f))
11402 return qe_invalid;
11403
11404
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_getc(&(temp_sub->colortype1),f))
11405 return qe_invalid;
11406
11407
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetw(&(temp_sub->color1),f))
11408 return qe_invalid;
11409
11410
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_getc(&(temp_sub->colortype2),f))
11411 return qe_invalid;
11412
11413
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetw(&(temp_sub->color2),f))
11414 return qe_invalid;
11415
11416
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_getc(&(temp_sub->colortype3),f))
11417 return qe_invalid;
11418
11419
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetw(&(temp_sub->color3),f))
11420 return qe_invalid;
11421
11422
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetd(&(temp_sub->d1),f))
11423 return qe_invalid;
11424
11425
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetd(&(temp_sub->d2),f))
11426 return qe_invalid;
11427
11428
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetd(&(temp_sub->d3),f))
11429 return qe_invalid;
11430
11431
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetd(&(temp_sub->d4),f))
11432 return qe_invalid;
11433
11434
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetd(&(temp_sub->d5),f))
11435 return qe_invalid;
11436
11437
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetd(&(temp_sub->d6),f))
11438 return qe_invalid;
11439
11440
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetd(&(temp_sub->d7),f))
11441 return qe_invalid;
11442
11443
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetd(&(temp_sub->d8),f))
11444 return qe_invalid;
11445
11446
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetd(&(temp_sub->d9),f))
11447 return qe_invalid;
11448
11449
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetd(&(temp_sub->d10),f))
11450 return qe_invalid;
11451
11452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46722 times.
46722 if(s_version < 2)
11453 {
11454 if(!p_igetl(&(temp_sub->speed),f))
11455 return qe_invalid;
11456
11457 if(!p_igetl(&(temp_sub->delay),f))
11458 return qe_invalid;
11459
11460 if(!p_igetl(&(temp_sub->frame),f))
11461 return qe_invalid;
11462 }
11463 else
11464 {
11465
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_getc(&(temp_sub->speed),f))
11466 return qe_invalid;
11467
11468
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_getc(&(temp_sub->delay),f))
11469 return qe_invalid;
11470
11471
1/2
✓ Branch 0 taken 46722 times.
✗ Branch 1 not taken.
46722 if(!p_igetw(&(temp_sub->frame),f))
11472 return qe_invalid;
11473 }
11474
11475 46722 int32_t temp_size=0;
11476
11477 // bool deletets = false;
11478
4/4
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 3476 times.
✓ Branch 2 taken 22168 times.
✓ Branch 3 taken 250 times.
46722 switch(temp_sub->type)
11479 {
11480 case ssoTEXT:
11481 case ssoTEXTBOX:
11482 case ssoCURRENTITEMTEXT:
11483 case ssoCURRENTITEMCLASSTEXT:
11484 {
11485 word temptempsize;
11486
11487
1/2
✓ Branch 0 taken 3476 times.
✗ Branch 1 not taken.
3476 if(!p_igetw(&temptempsize,f))
11488 {
11489 return qe_invalid;
11490 }
11491
11492 //temptempsize = temp1 + (temp2 << 8);
11493 3476 temp_size = (int32_t)temptempsize;
11494 3476 uint32_t char_length = temp_size+2;
11495
1/2
✓ Branch 0 taken 3476 times.
✗ Branch 1 not taken.
3476 if (char_length > MAX_DP1_LEN)
11496 {
11497 return qe_invalid;
11498 }
11499 3476 tempdp1[char_length - 1] = '\0';
11500
11501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3476 times.
3476 if(temp_size)
11502
1/2
✓ Branch 0 taken 3476 times.
✗ Branch 1 not taken.
3476 if(!pfread(tempdp1,temp_size+1,f))
11503 return qe_invalid;
11504 3476 break;
11505 }
11506
11507 case ssoLIFEMETER:
11508
1/2
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
250 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11509 temp_sub->d3 = 1;
11510
11511
1/2
✓ Branch 0 taken 250 times.
✗ Branch 1 not taken.
250 if(!p_getc(&(temp_sub->dp1),f))
11512 return qe_invalid;
11513
11514 250 break;
11515
11516
11517 case ssoCURRENTITEM:
11518
11519
1/2
✓ Branch 0 taken 20828 times.
✗ Branch 1 not taken.
20828 if(s_version < 6)
11520 {
11521 switch(temp_sub->d1)
11522 {
11523 case ssiBOMB:
11524 temp_sub->d1 = itype_bomb;
11525 break;
11526
11527 case ssiSWORD:
11528 temp_sub->d1 = itype_sword;
11529 break;
11530
11531 case ssiSHIELD:
11532 temp_sub->d1 = itype_shield;
11533 break;
11534
11535 case ssiCANDLE:
11536 temp_sub->d1 = itype_candle;
11537 break;
11538
11539 case ssiLETTER:
11540 temp_sub->d1 = itype_letter;
11541 break;
11542
11543 case ssiPOTION:
11544 temp_sub->d1 = itype_potion;
11545 break;
11546
11547 case ssiLETTERPOTION:
11548 temp_sub->d1 = itype_letterpotion;
11549 break;
11550
11551 case ssiBOW:
11552 temp_sub->d1 = itype_bow;
11553 break;
11554
11555 case ssiARROW:
11556 temp_sub->d1 = itype_arrow;
11557 break;
11558
11559 case ssiBOWANDARROW:
11560 temp_sub->d1 = itype_bowandarrow;
11561 break;
11562
11563 case ssiBAIT:
11564 temp_sub->d1 = itype_bait;
11565 break;
11566
11567 case ssiRING:
11568 temp_sub->d1 = itype_ring;
11569 break;
11570
11571 case ssiBRACELET:
11572 temp_sub->d1 = itype_bracelet;
11573 break;
11574
11575 case ssiMAP:
11576 temp_sub->d1 = itype_map;
11577 break;
11578
11579 case ssiCOMPASS:
11580 temp_sub->d1 = itype_compass;
11581 break;
11582
11583 case ssiBOSSKEY:
11584 temp_sub->d1 = itype_bosskey;
11585 break;
11586
11587 case ssiMAGICKEY:
11588 temp_sub->d1 = itype_magickey;
11589 break;
11590
11591 case ssiBRANG:
11592 temp_sub->d1 = itype_brang;
11593 break;
11594
11595 case ssiWAND:
11596 temp_sub->d1 = itype_wand;
11597 break;
11598
11599 case ssiRAFT:
11600 temp_sub->d1 = itype_raft;
11601 break;
11602
11603 case ssiLADDER:
11604 temp_sub->d1 = itype_ladder;
11605 break;
11606
11607 case ssiWHISTLE:
11608 temp_sub->d1 = itype_whistle;
11609 break;
11610
11611 case ssiBOOK:
11612 temp_sub->d1 = itype_book;
11613 break;
11614
11615 case ssiWALLET:
11616 temp_sub->d1 = itype_wallet;
11617 break;
11618
11619 case ssiSBOMB:
11620 temp_sub->d1 = itype_sbomb;
11621 break;
11622
11623 case ssiHCPIECE:
11624 temp_sub->d1 = itype_heartpiece;
11625 break;
11626
11627 case ssiAMULET:
11628 temp_sub->d1 = itype_amulet;
11629 break;
11630
11631 case ssiFLIPPERS:
11632 temp_sub->d1 = itype_flippers;
11633 break;
11634
11635 case ssiHOOKSHOT:
11636 temp_sub->d1 = itype_hookshot;
11637 break;
11638
11639 case ssiLENS:
11640 temp_sub->d1 = itype_lens;
11641 break;
11642
11643 case ssiHAMMER:
11644 temp_sub->d1 = itype_hammer;
11645 break;
11646
11647 case ssiBOOTS:
11648 temp_sub->d1 = itype_boots;
11649 break;
11650
11651 case ssiDIVINEFIRE:
11652 temp_sub->d1 = itype_divinefire;
11653 break;
11654
11655 case ssiDIVINEESCAPE:
11656 temp_sub->d1 = itype_divineescape;
11657 break;
11658
11659 case ssiDIVINEPROTECTION:
11660 temp_sub->d1 = itype_divineprotection;
11661 break;
11662
11663 case ssiQUIVER:
11664 temp_sub->d1 = itype_quiver;
11665 break;
11666
11667 case ssiBOMBBAG:
11668 temp_sub->d1 = itype_bombbag;
11669 break;
11670
11671 case ssiCBYRNA:
11672 temp_sub->d1 = itype_cbyrna;
11673 break;
11674
11675 case ssiROCS:
11676 temp_sub->d1 = itype_rocs;
11677 break;
11678
11679 case ssiHOVERBOOTS:
11680 temp_sub->d1 = itype_hoverboots;
11681 break;
11682
11683 case ssiSPINSCROLL:
11684 temp_sub->d1 = itype_spinscroll;
11685 break;
11686
11687 case ssiCROSSSCROLL:
11688 temp_sub->d1 = itype_crossscroll;
11689 break;
11690
11691 case ssiQUAKESCROLL:
11692 temp_sub->d1 = itype_quakescroll;
11693 break;
11694
11695 case ssiWHISPRING:
11696 temp_sub->d1 = itype_whispring;
11697 break;
11698
11699 case ssiCHARGERING:
11700 temp_sub->d1 = itype_chargering;
11701 break;
11702
11703 case ssiPERILSCROLL:
11704 temp_sub->d1 = itype_perilscroll;
11705 break;
11706
11707 case ssiWEALTHMEDAL:
11708 temp_sub->d1 = itype_wealthmedal;
11709 break;
11710
11711 case ssiHEARTRING:
11712 temp_sub->d1 = itype_heartring;
11713 break;
11714
11715 case ssiMAGICRING:
11716 temp_sub->d1 = itype_magicring;
11717 break;
11718
11719 case ssiSPINSCROLL2:
11720 temp_sub->d1 = itype_spinscroll2;
11721 break;
11722
11723 case ssiQUAKESCROLL2:
11724 temp_sub->d1 = itype_quakescroll2;
11725 break;
11726
11727 case ssiAGONY:
11728 temp_sub->d1 = itype_agony;
11729 break;
11730
11731 case ssiSTOMPBOOTS:
11732 temp_sub->d1 = itype_stompboots;
11733 break;
11734
11735 case ssiWHIMSICALRING:
11736 temp_sub->d1 = itype_whimsicalring;
11737 break;
11738
11739 case ssiPERILRING:
11740 temp_sub->d1 = itype_perilring;
11741 break;
11742
11743 default:
11744 temp_sub->d1 += itype_custom1 - ssiMAX;
11745 }
11746 }
11747
11748 //fall-through
11749 default:
11750
1/2
✓ Branch 0 taken 42996 times.
✗ Branch 1 not taken.
42996 if(!p_getc(&(temp_sub->dp1),f))
11751 return qe_invalid;
11752
11753 42996 break;
11754 }
11755
11756
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 38028 times.
46722 if(s_version < 7)
11757 {
11758
3/3
✓ Branch 0 taken 31990 times.
✓ Branch 1 taken 1366 times.
✓ Branch 2 taken 4672 times.
38028 switch(temp_sub->type)
11759 {
11760 case ssoMAGICGAUGE:
11761 {
11762
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1248 times.
1366 if(!temp_sub->d9)
11763 1248 temp_sub->d9 = -1; //-1 now represents 'always'
11764 1366 break;
11765 }
11766 case ssoLIFEGAUGE:
11767 4672 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11768 4672 break;
11769 }
11770 38028 }
11771
11772
3/3
✓ Branch 0 taken 3476 times.
✓ Branch 1 taken 41654 times.
✓ Branch 2 taken 1592 times.
46722 switch(temp_sub->type)
11773 {
11774 case ssoTEXT:
11775 case ssoTEXTBOX:
11776 case ssoCURRENTITEMTEXT:
11777 case ssoCURRENTITEMCLASSTEXT:
11778
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3476 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3476 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11779
11780 3476 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11781 3476 g->objects[j].dp1 = new char[temp_size+2];
11782 3476 strcpy((char*)g->objects[j].dp1,tempdp1);
11783 3476 break;
11784
11785 case ssoCOUNTER:
11786
1/2
✓ Branch 0 taken 1592 times.
✗ Branch 1 not taken.
1592 if(s_version<3)
11787 {
11788 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11789 temp_sub->d8=0;
11790 }
11791
11792 default:
11793 43246 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11794 43246 break;
11795 }
11796
11797 46722 g->name[0] = '\0';
11798 46722 strncat(g->name, tempname, 64 - 1);
11799 46722 g->ss_type = temp_ss;
11800 46722 }
11801
11802
2/2
✓ Branch 0 taken 7195006 times.
✓ Branch 1 taken 28288 times.
7223294 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11803 {
11804 //clear all unused object in this subscreen -DD
11805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7195006 times.
7195006 switch(g->objects[j].type)
11806 {
11807 case ssoTEXT:
11808 case ssoTEXTBOX:
11809 case ssoCURRENTITEMTEXT:
11810 case ssoCURRENTITEMCLASSTEXT:
11811 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11812
11813 //fall through
11814 default:
11815 7195006 memset(&g->objects[j],0,sizeof(subscreen_object));
11816 7195006 break;
11817 }
11818 7195006 }
11819
11820 28288 return 0;
11821 28288 }
11822
11823 384 int32_t readsubscreens(PACKFILE *f)
11824 {
11825 word s_version;
11826 dword dummy;
11827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_igetw(&s_version,f))
11828 return qe_invalid;
11829 384 FFCore.quest_format[vSubscreen] = s_version;
11830
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
11831 return qe_invalid;
11832
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&dummy,f)) //section size
11833 return qe_invalid;
11834
11835
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 163 times.
384 if(s_version < 8)
11836 221 return read_old_subscreens(f,s_version);
11837
11838 163 subscreens_active.clear();
11839 163 subscreens_passive.clear();
11840 163 subscreens_overlay.clear();
11841
11842 byte sz;
11843
1/2
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
163 if(!p_getc(&sz,f))
11844 return qe_invalid;
11845
2/2
✓ Branch 0 taken 524 times.
✓ Branch 1 taken 163 times.
687 for(byte q = 0; q < sz; ++q)
11846 {
11847 524 ZCSubscreen& tmp = subscreens_active.emplace_back();
11848
1/2
✓ Branch 0 taken 524 times.
✗ Branch 1 not taken.
524 if (auto ret = tmp.read(f, s_version))
11849 return ret;
11850 524 }
11851
1/2
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
163 if(!p_getc(&sz,f))
11852 return qe_invalid;
11853
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 163 times.
678 for(byte q = 0; q < sz; ++q)
11854 {
11855 515 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11856
1/2
✓ Branch 0 taken 515 times.
✗ Branch 1 not taken.
515 if (auto ret = tmp.read(f, s_version))
11857 return ret;
11858 515 }
11859
1/2
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
163 if(!p_getc(&sz,f))
11860 return qe_invalid;
11861
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 163 times.
169 for(byte q = 0; q < sz; ++q)
11862 {
11863 6 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (auto ret = tmp.read(f, s_version))
11865 return ret;
11866 6 }
11867 163 return 0;
11868 384 }
11869
11870 void reset_subscreen(subscreen_group *tempss)
11871 {
11872 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11873 {
11874 switch(tempss->objects[i].type)
11875 {
11876 case ssoTEXT:
11877 case ssoTEXTBOX:
11878 case ssoCURRENTITEMTEXT:
11879 case ssoCURRENTITEMCLASSTEXT:
11880 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11881
11882 //fall through
11883 default:
11884 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11885 break;
11886 }
11887 }
11888 }
11889
11890 116 void reset_subscreens()
11891 {
11892 116 subscreens_active.clear();
11893 116 subscreens_passive.clear();
11894 116 subscreens_overlay.clear();
11895 116 }
11896
11897 116 int32_t setupsubscreens()
11898 {
11899 116 reset_subscreens();
11900 //return 0;
11901
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 232 times.
348 for(int q = 0; q < 2; ++q)
11902 {
11903 232 subscreens_active.emplace_back();
11904 232 subscreens_passive.emplace_back();
11905 232 }
11906 116 int32_t tempsubscreen=subscr_mode;
11907
11908
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(tempsubscreen>=ssdtMAX)
11909 tempsubscreen=0;
11910
11911
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✗ Branch 2 not taken.
116 switch(tempsubscreen)
11912 {
11913 case ssdtOLD:
11914 case ssdtNEWSUBSCR:
11915 case ssdtREV2:
11916 case ssdtBSZELDA:
11917 case ssdtBSZELDAMODIFIED:
11918 case ssdtBSZELDAENHANCED:
11919 case ssdtBSZELDACOMPLETE:
11920 {
11921 116 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11922 116 subscreens_active[0].sub_type=sstACTIVE;
11923 116 subscreens_active[0].name = "Active Subscreen (Triforce)";
11924 116 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11925 116 subscreens_active[1].sub_type=sstACTIVE;
11926 116 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11927 116 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11928 116 subscreens_passive[0].sub_type=sstPASSIVE;
11929 116 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11930 116 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11931 116 subscreens_passive[1].sub_type=sstPASSIVE;
11932 116 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11933 116 break;
11934 }
11935
11936 case ssdtZ3:
11937 {
11938 subscreens_active[0].load_old(z3_active_a);
11939 subscreens_active[0].sub_type=sstACTIVE;
11940 subscreens_active[1].load_old(z3_active_ab);
11941 subscreens_active[1].sub_type=sstACTIVE;
11942 subscreens_passive[0].load_old(z3_passive_a);
11943 subscreens_passive[0].sub_type=sstPASSIVE;
11944 subscreens_passive[1].load_old(z3_passive_ab);
11945 subscreens_passive[1].sub_type=sstPASSIVE;
11946 break;
11947 }
11948 }
11949 116 subscr_mode = ssdtMAX;
11950 116 return 0;
11951 }
11952
11953 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
11954
11955 extern script_data *ffscripts[NUMSCRIPTFFC];
11956 extern script_data *itemscripts[NUMSCRIPTITEM];
11957 extern script_data *guyscripts[NUMSCRIPTGUYS];
11958 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11959 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11960 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11961 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11962 extern script_data *playerscripts[NUMSCRIPTHERO];
11963 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11964 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11965 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11966 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11967 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11968
11969 static std::vector<const script_data*> read_scripts;
11970
11971 436 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11972 {
11973 int32_t dummy;
11974 436 word s_version=0, zmeta_version=0;
11975 436 byte numscripts=0;
11976 436 numscripts=numscripts; //to avoid unused variables warnings
11977 int32_t ret;
11978 436 read_scripts.clear();
11979 436 zasm_scripts.clear();
11980
11981 //section version info
11982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 if(!p_igetw(&s_version,f))
11983 {
11984 return qe_invalid;
11985 }
11986
11987 436 FFCore.quest_format[vFFScript] = s_version;
11988
11989
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!read_deprecated_section_cversion(f))
11990 {
11991 return qe_invalid;
11992 }
11993
11994
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 180 times.
436 if(s_version >= 18)
11995 {
11996
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_igetw(&zmeta_version,f))
11997 {
11998 return qe_invalid;
11999 }
12000 180 }
12001
12002 //section size
12003
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_igetl(&dummy,f))
12004 {
12005 return qe_invalid;
12006 }
12007
12008
2/2
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 223 times.
436 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12009 436 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12010
12011
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 114 times.
436 if(s_version >= 27)
12012 {
12013 114 ret = read_quest_zasm(f, s_version);
12014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(ret)
12015 return qe_invalid;
12016 114 }
12017
12018 //finally... section data
12019
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 370 times.
196978 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12020 {
12021 196608 ret = read_one_ffscript(f, Header, i, s_version, ffscripts[i], zmeta_version);
12022
12023
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if (ret)
12024 {
12025 return qe_invalid;
12026 }
12027 196608 }
12028
12029 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12030 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12031 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12032 * there was a version bump a week before a change that broke stuff.
12033 */
12034
7/8
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180 times.
✓ Branch 4 taken 180 times.
✓ Branch 5 taken 180 times.
✓ Branch 6 taken 180 times.
✓ Branch 7 taken 180 times.
370 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12035 {
12036 550 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12037 550 }
12038
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 204 times.
384 if(s_version < 19)
12039 {
12040 204 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12041 204 }
12042
12043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(s_version > 1)
12044 {
12045
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 384 times.
98688 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12046 {
12047 98304 ret = read_one_ffscript(f, Header, i, s_version, itemscripts[i], zmeta_version);
12048
12049
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if (ret)
12050 {
12051 return qe_invalid;
12052 }
12053 98304 }
12054
12055
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 384 times.
98688 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12056 {
12057 98304 ret = read_one_ffscript(f, Header, i, s_version, guyscripts[i], zmeta_version);
12058
12059
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if (ret)
12060 {
12061 return qe_invalid;
12062 }
12063 98304 }
12064
12065
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 script_data *fake = new script_data(ScriptType::None, 0);
12066
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 384 times.
98688 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12067 {
12068 98304 ret = read_one_ffscript(f, Header, i, s_version, fake, zmeta_version);
12069
12070
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if (ret)
12071 {
12072 return qe_invalid;
12073 }
12074 98304 }
12075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 delete fake;
12076
12077
2/2
✓ Branch 0 taken 98304 times.
✓ Branch 1 taken 384 times.
98688 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12078 {
12079 98304 ret = read_one_ffscript(f, Header, i, s_version, screenscripts[i], zmeta_version);
12080
12081
1/2
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
98304 if (ret)
12082 {
12083 return qe_invalid;
12084 }
12085 98304 }
12086
12087
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 204 times.
384 if(s_version > 16)
12088 {
12089
2/2
✓ Branch 0 taken 1440 times.
✓ Branch 1 taken 180 times.
1620 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12090 {
12091 1440 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12092
12093
1/2
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
1440 if (ret)
12094 {
12095 return qe_invalid;
12096 }
12097 1440 }
12098 180 }
12099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 else if(s_version > 13)
12100 {
12101 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12102 {
12103 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12104
12105 if (ret)
12106 {
12107 return qe_invalid;
12108 }
12109 }
12110
12111 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12112 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12113
12114 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12115 }
12116
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 else if(s_version > 4)
12117 {
12118
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 204 times.
1020 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12119 {
12120 816 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12121
12122
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 if (ret)
12123 {
12124 return qe_invalid;
12125 }
12126 816 }
12127
12128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12129
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12130
12131
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12132
12133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12134
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12135
12136
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12137
12138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12139
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 delete globalscripts[GLOBAL_SCRIPT_F6];
12140
12141
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12142
12143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12144
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12145
12146
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12147 204 }
12148 else
12149 {
12150 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12151 {
12152 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12153
12154 if (ret)
12155 {
12156 return qe_invalid;
12157 }
12158 }
12159
12160 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12161 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12162
12163 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12164
12165 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12166 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12167
12168 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12169
12170 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12171 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12172
12173 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12174
12175 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12176 delete globalscripts[GLOBAL_SCRIPT_F6];
12177
12178 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12179
12180 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12181 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12182
12183 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12184 }
12185
12186
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 204 times.
384 if(s_version > 10) //expanded the number of Hero scripts to 5.
12187 {
12188
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 180 times.
1080 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
12189 {
12190 900 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12191
12192
1/2
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
900 if (ret)
12193 {
12194 return qe_invalid;
12195 }
12196 900 }
12197 180 }
12198 else
12199 {
12200
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 204 times.
816 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12201 {
12202 612 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12203
12204
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if (ret)
12205 {
12206 return qe_invalid;
12207 }
12208 612 }
12209
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(playerscripts[3] != NULL)
12210
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 delete playerscripts[3];
12211
12212
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 playerscripts[3] = new script_data(ScriptType::Hero, 3);
12213
12214
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(playerscripts[4] != NULL)
12215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 delete playerscripts[4];
12216
12217
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 playerscripts[4] = new script_data(ScriptType::Hero, 4);
12218 }
12219
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
384 if(s_version > 8 && s_version < 10)
12220 {
12221
12222 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12223 {
12224 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12225
12226 if (ret)
12227 {
12228 return qe_invalid;
12229 }
12230 }
12231 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12232 {
12233 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12234
12235 if (ret)
12236 {
12237 return qe_invalid;
12238 }
12239 }
12240
12241 }
12242
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 180 times.
384 if(s_version >= 10)
12243 {
12244
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 180 times.
46260 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12245 {
12246 46080 ret = read_one_ffscript(f, Header, i, s_version, lwpnscripts[i], zmeta_version);
12247
12248
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if (ret)
12249 {
12250 return qe_invalid;
12251 }
12252 46080 }
12253
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 180 times.
46260 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12254 {
12255 46080 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12256
12257
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if (ret)
12258 {
12259 return qe_invalid;
12260 }
12261 46080 }
12262
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 180 times.
46260 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12263 {
12264 46080 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12265
12266
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if (ret)
12267 {
12268 return qe_invalid;
12269 }
12270 46080 }
12271
12272 180 }
12273
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 180 times.
384 if(s_version >=12)
12274 {
12275
2/2
✓ Branch 0 taken 46080 times.
✓ Branch 1 taken 180 times.
46260 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12276 {
12277 46080 ret = read_one_ffscript(f, Header, i, s_version, itemspritescripts[i], zmeta_version);
12278
12279
1/2
✓ Branch 0 taken 46080 times.
✗ Branch 1 not taken.
46080 if (ret)
12280 {
12281 return qe_invalid;
12282 }
12283 46080 }
12284 180 }
12285
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 180 times.
384 if(s_version >=15)
12286 {
12287
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 180 times.
92340 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12288 {
12289 92160 ret = read_one_ffscript(f, Header, i, s_version, comboscripts[i], zmeta_version);
12290
12291
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if (ret)
12292 {
12293 return qe_invalid;
12294 }
12295 92160 }
12296 180 }
12297
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 180 times.
384 if(s_version >19)
12298 {
12299 180 word numgenscripts = NUMSCRIPTSGENERIC;
12300
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_igetw(&numgenscripts,f))
12301 {
12302 return qe_invalid;
12303 }
12304
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 180 times.
92340 for(int32_t i = 0; i < numgenscripts; i++)
12305 {
12306 92160 ret = read_one_ffscript(f, Header, i, s_version, genericscripts[i], zmeta_version);
12307
12308
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if (ret)
12309 {
12310 return qe_invalid;
12311 }
12312 92160 }
12313 180 }
12314
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 163 times.
384 if(s_version >21)
12315 {
12316 163 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12317
1/2
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
163 if(!p_igetw(&numsubscripts,f))
12318 {
12319 return qe_invalid;
12320 }
12321
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 163 times.
41891 for(int32_t i = 0; i < numsubscripts; i++)
12322 {
12323 41728 ret = read_one_ffscript(f, Header, i, s_version, subscreenscripts[i], zmeta_version);
12324
12325
1/2
✓ Branch 0 taken 41728 times.
✗ Branch 1 not taken.
41728 if (ret)
12326 {
12327 return qe_invalid;
12328 }
12329 41728 }
12330 163 }
12331 384 }
12332
12333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(s_version > 2)
12334 {
12335 int32_t bufsize;
12336 384 p_igetl(&bufsize, f);
12337
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if (bufsize < 0 || bufsize > 1024*1024*10)
12338 {
12339 // God help anyone storing more than 10MB of code in the script buffer.
12340 return qe_invalid;
12341 }
12342 384 char * buf = new char[bufsize+1];
12343 384 pfread(buf, bufsize, f);
12344 384 buf[bufsize]=0;
12345
12346
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 zScript = string(buf);
12347
12348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 delete[] buf;
12349 word numffcbindings;
12350 384 p_igetw(&numffcbindings, f);
12351
12352
2/2
✓ Branch 0 taken 9858 times.
✓ Branch 1 taken 384 times.
10242 for(int32_t i=0; i<numffcbindings; i++)
12353 {
12354 word id;
12355 9858 p_igetw(&id, f);
12356 9858 p_igetl(&bufsize, f);
12357
2/4
✓ Branch 0 taken 9858 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9858 times.
9858 if (bufsize < 0 || bufsize > 1024)
12358 return qe_invalid;
12359 9858 buf = new char[bufsize+1];
12360 9858 pfread(buf, bufsize, f);
12361 9858 buf[bufsize]=0;
12362
12363 //fix for buggy older saved quests -DD
12364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9858 times.
9858 if(id < NUMSCRIPTFFC-1)
12365 9858 ffcmap[id].scriptname = buf;
12366
12367
1/2
✓ Branch 0 taken 9858 times.
✗ Branch 1 not taken.
9858 delete[] buf;
12368 9858 }
12369
12370 word numglobalbindings;
12371 384 p_igetw(&numglobalbindings, f);
12372
12373
2/2
✓ Branch 0 taken 1572 times.
✓ Branch 1 taken 384 times.
1956 for(int32_t i=0; i<numglobalbindings; i++)
12374 {
12375 word id;
12376 1572 p_igetw(&id, f);
12377 1572 p_igetl(&bufsize, f);
12378
2/4
✓ Branch 0 taken 1572 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1572 times.
1572 if (bufsize < 0 || bufsize > 1024)
12379 return qe_invalid;
12380 1572 buf = new char[bufsize+1];
12381 1572 pfread(buf, bufsize, f);
12382 1572 buf[bufsize]=0;
12383
12384 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12385 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12386 // Ignore these. -DD
12387
2/2
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 1014 times.
1572 if (id < NUMSCRIPTGLOBAL)
12388 {
12389 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12390
1/2
✓ Branch 0 taken 1014 times.
✗ Branch 1 not taken.
1014 if(strcmp(buf,"~Continue") == 0)
12391 {
12392 globalmap[id].scriptname = "";
12393
12394 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12395 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12396 }
12397 else
12398 {
12399 1014 globalmap[id].scriptname = buf;
12400 }
12401 1014 }
12402
12403
1/2
✓ Branch 0 taken 1572 times.
✗ Branch 1 not taken.
1572 delete[] buf;
12404 1572 }
12405
12406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(s_version > 3)
12407 {
12408 word numitembindings;
12409 384 p_igetw(&numitembindings, f);
12410
12411
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 384 times.
1664 for(int32_t i=0; i<numitembindings; i++)
12412 {
12413 word id;
12414 1280 p_igetw(&id, f);
12415 1280 p_igetl(&bufsize, f);
12416
2/4
✓ Branch 0 taken 1280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1280 times.
✗ Branch 3 not taken.
1280 if (bufsize < 0 || bufsize > 1024)
12417 return qe_invalid;
12418 1280 buf = new char[bufsize+1];
12419 1280 pfread(buf, bufsize, f);
12420 1280 buf[bufsize]=0;
12421
12422 //fix this too
12423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1280 times.
1280 if(id <NUMSCRIPTITEM-1)
12424 1280 itemmap[id].scriptname = buf;
12425
12426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1280 times.
1280 delete[] buf;
12427 1280 }
12428 384 }
12429 //(v9+)
12430
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 180 times.
384 if(s_version > 8)
12431 {
12432 //npc scripts
12433 word numnpcbindings;
12434 180 p_igetw(&numnpcbindings, f);
12435
12436
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 180 times.
212 for(int32_t i=0; i<numnpcbindings; i++)
12437 {
12438 word id;
12439 32 p_igetw(&id, f);
12440 32 p_igetl(&bufsize, f);
12441
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 if (bufsize < 0 || bufsize > 1024)
12442 return qe_invalid;
12443 32 buf = new char[bufsize+1];
12444 32 pfread(buf, bufsize, f);
12445 32 buf[bufsize]=0;
12446
12447 //fix this too
12448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(id <NUMSCRIPTGUYS-1)
12449 32 npcmap[id].scriptname = buf;
12450
12451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 delete[] buf;
12452 32 }
12453 //lweapon
12454 word numlwpnbindings;
12455 180 p_igetw(&numlwpnbindings, f);
12456
12457
2/2
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 180 times.
502 for(int32_t i=0; i<numlwpnbindings; i++)
12458 {
12459 word id;
12460 322 p_igetw(&id, f);
12461 322 p_igetl(&bufsize, f);
12462
2/4
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 322 times.
✗ Branch 3 not taken.
322 if (bufsize < 0 || bufsize > 1024)
12463 return qe_invalid;
12464 322 buf = new char[bufsize+1];
12465 322 pfread(buf, bufsize, f);
12466 322 buf[bufsize]=0;
12467
12468 //fix this too
12469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if(id <NUMSCRIPTWEAPONS-1)
12470 322 lwpnmap[id].scriptname = buf;
12471
12472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 delete[] buf;
12473 322 }
12474 //eweapon
12475 word numewpnbindings;
12476 180 p_igetw(&numewpnbindings, f);
12477
12478
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 180 times.
477 for(int32_t i=0; i<numewpnbindings; i++)
12479 {
12480 word id;
12481 297 p_igetw(&id, f);
12482 297 p_igetl(&bufsize, f);
12483
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if (bufsize < 0 || bufsize > 1024)
12484 return qe_invalid;
12485 297 buf = new char[bufsize+1];
12486 297 pfread(buf, bufsize, f);
12487 297 buf[bufsize]=0;
12488
12489 //fix this too
12490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(id <NUMSCRIPTWEAPONS-1)
12491 297 ewpnmap[id].scriptname = buf;
12492
12493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 delete[] buf;
12494 297 }
12495 //hero
12496 word numherobindings;
12497 180 p_igetw(&numherobindings, f);
12498
12499
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 180 times.
203 for(int32_t i=0; i<numherobindings; i++)
12500 {
12501 word id;
12502 23 p_igetw(&id, f);
12503 23 p_igetl(&bufsize, f);
12504
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if (bufsize < 0 || bufsize > 1024)
12505 return qe_invalid;
12506 23 buf = new char[bufsize+1];
12507 23 pfread(buf, bufsize, f);
12508 23 buf[bufsize]=0;
12509
12510 //fix this too
12511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTHERO-1)
12512 23 playermap[id].scriptname = buf;
12513
12514
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 delete[] buf;
12515 23 }
12516 //dmaps
12517 word numdmapbindings;
12518 180 p_igetw(&numdmapbindings, f);
12519
12520
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 180 times.
588 for(int32_t i=0; i<numdmapbindings; i++)
12521 {
12522 word id;
12523 408 p_igetw(&id, f);
12524 408 p_igetl(&bufsize, f);
12525
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 if (bufsize < 0 || bufsize > 1024)
12526 return qe_invalid;
12527 408 buf = new char[bufsize+1];
12528 408 pfread(buf, bufsize, f);
12529 408 buf[bufsize]=0;
12530
12531 //fix this too
12532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(id <NUMSCRIPTSDMAP-1)
12533 408 dmapmap[id].scriptname = buf;
12534
12535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 delete[] buf;
12536 408 }
12537 //screen
12538 word numscreenbindings;
12539 180 p_igetw(&numscreenbindings, f);
12540
12541
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 180 times.
584 for(int32_t i=0; i<numscreenbindings; i++)
12542 {
12543 word id;
12544 404 p_igetw(&id, f);
12545 404 p_igetl(&bufsize, f);
12546
2/4
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 404 times.
✗ Branch 3 not taken.
404 if (bufsize < 0 || bufsize > 1024)
12547 return qe_invalid;
12548 404 buf = new char[bufsize+1];
12549 404 pfread(buf, bufsize, f);
12550 404 buf[bufsize]=0;
12551
12552 //fix this too
12553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
404 if(id <NUMSCRIPTSDMAP-1)
12554 404 screenmap[id].scriptname = buf;
12555
12556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
404 delete[] buf;
12557 404 }
12558 180 }
12559
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 180 times.
384 if(s_version > 11)
12560 {
12561 word numspritebindings;
12562 180 p_igetw(&numspritebindings, f);
12563
12564
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 180 times.
229 for(int32_t i=0; i<numspritebindings; i++)
12565 {
12566 word id;
12567 49 p_igetw(&id, f);
12568 49 p_igetl(&bufsize, f);
12569
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
49 if (bufsize < 0 || bufsize > 1024)
12570 return qe_invalid;
12571 49 buf = new char[bufsize+1];
12572 49 pfread(buf, bufsize, f);
12573 49 buf[bufsize]=0;
12574
12575 //fix this too
12576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if(id <NUMSCRIPTSDMAP-1)
12577 49 itemspritemap[id].scriptname = buf;
12578
12579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 delete[] buf;
12580 49 }
12581 180 }
12582
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 180 times.
384 if(s_version >= 15)
12583 {
12584 word numcombobindings;
12585 180 p_igetw(&numcombobindings, f);
12586
12587
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 180 times.
337 for(int32_t i=0; i<numcombobindings; i++)
12588 {
12589 word id;
12590 157 p_igetw(&id, f);
12591 157 p_igetl(&bufsize, f);
12592
2/4
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 157 times.
157 if (bufsize < 0 || bufsize > 1024)
12593 return qe_invalid;
12594 157 buf = new char[bufsize+1];
12595 157 pfread(buf, bufsize, f);
12596 157 buf[bufsize]=0;
12597
12598 //fix this too
12599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 if(id <NUMSCRIPTSCOMBODATA-1)
12600 157 comboscriptmap[id].scriptname = buf;
12601
12602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 delete[] buf;
12603 157 }
12604 180 }
12605
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 180 times.
384 if(s_version > 19)
12606 {
12607 word numgenericbindings;
12608 180 p_igetw(&numgenericbindings, f);
12609
12610
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 180 times.
1414 for(int32_t i=0; i<numgenericbindings; i++)
12611 {
12612 word id;
12613 1234 p_igetw(&id, f);
12614 1234 p_igetl(&bufsize, f);
12615
2/4
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1234 times.
1234 if (bufsize < 0 || bufsize > 1024)
12616 return qe_invalid;
12617 1234 buf = new char[bufsize+1];
12618 1234 pfread(buf, bufsize, f);
12619 1234 buf[bufsize]=0;
12620
12621 //fix this too
12622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 if(id <NUMSCRIPTSGENERIC-1)
12623 1234 genericmap[id].scriptname = buf;
12624
12625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 delete[] buf;
12626 1234 }
12627 180 }
12628
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 163 times.
384 if(s_version > 21)
12629 {
12630 word numsubscreenbindings;
12631 163 p_igetw(&numsubscreenbindings, f);
12632
12633
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 163 times.
171 for(int32_t i=0; i<numsubscreenbindings; i++)
12634 {
12635 word id;
12636 8 p_igetw(&id, f);
12637 8 p_igetl(&bufsize, f);
12638
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if (bufsize < 0 || bufsize > 1024)
12639 return qe_invalid;
12640 8 buf = new char[bufsize+1];
12641 8 pfread(buf, bufsize, f);
12642 8 buf[bufsize]=0;
12643
12644 //fix this too
12645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(id <NUMSCRIPTSSUBSCREEN-1)
12646 8 subscreenmap[id].scriptname = buf;
12647
12648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 delete[] buf;
12649 8 }
12650 163 }
12651 384 }
12652
12653 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12654 // This is only updated when the scripts have been recompiled.
12655 // They should all match each other.
12656 384 std::optional<word> zscript_version;
12657
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 180 times.
384 if (s_version >= 16)
12658 {
12659
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 6198 times.
6376 for (auto script : read_scripts)
12660 {
12661
2/2
✓ Branch 0 taken 6196 times.
✓ Branch 1 taken 2 times.
6198 if (script->meta.ffscript_v == 0)
12662 {
12663 // These scripts were saved in a version prior to this field being set.
12664 // See https://discord.com/channels/876899628556091432/1368485306394738718
12665 2 zscript_version = 16;
12666 2 break;
12667 }
12668
1/2
✓ Branch 0 taken 6196 times.
✗ Branch 1 not taken.
6196 if (script->meta.ffscript_v > s_version)
12669 break;
12670
12671
2/2
✓ Branch 0 taken 6035 times.
✓ Branch 1 taken 161 times.
6196 if (!zscript_version.has_value())
12672 {
12673 161 zscript_version = script->meta.ffscript_v;
12674 161 continue;
12675 }
12676
12677
1/2
✓ Branch 0 taken 6035 times.
✗ Branch 1 not taken.
6035 if (zscript_version.value() != script->meta.ffscript_v)
12678 {
12679 zscript_version.reset();
12680 break;
12681 }
12682 }
12683
12684
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 17 times.
180 if (!zscript_version.has_value())
12685 17 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12686 180 }
12687 384 setZScriptVersion(zscript_version.value_or(s_version));
12688 384 read_scripts.clear();
12689
12690 384 return 0;
12691 384 }
12692
12693 void(*reset_scripts_hook)();
12694
12695 466 void reset_scripts()
12696 {
12697 // We can't modify the script data while jit threads are possibly compiling them.
12698
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 455 times.
466 if (reset_scripts_hook)
12699 455 reset_scripts_hook();
12700
12701
2/2
✓ Branch 0 taken 238592 times.
✓ Branch 1 taken 466 times.
239058 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12702 {
12703
1/2
✓ Branch 0 taken 238592 times.
✗ Branch 1 not taken.
238592 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12704 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12705 238592 }
12706
12707
2/2
✓ Branch 0 taken 238592 times.
✓ Branch 1 taken 466 times.
239058 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12708 {
12709
1/2
✓ Branch 0 taken 238592 times.
✗ Branch 1 not taken.
238592 if (ffscripts[i])
12710 238592 ffscripts[i]->disable();
12711 else
12712 ffscripts[i] = new script_data(ScriptType::FFC, i);
12713 238592 }
12714
12715
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12716 {
12717
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (itemscripts[i])
12718 119296 itemscripts[i]->disable();
12719 else
12720 itemscripts[i] = new script_data(ScriptType::Item, i);
12721 119296 }
12722
12723
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12724 {
12725
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (guyscripts[i])
12726 119296 guyscripts[i]->disable();
12727 else
12728 guyscripts[i] = new script_data(ScriptType::NPC, i);
12729 119296 }
12730
12731
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12732 {
12733
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (screenscripts[i])
12734 119296 screenscripts[i]->disable();
12735 else
12736 screenscripts[i] = new script_data(ScriptType::Screen, i);
12737 119296 }
12738
12739
2/2
✓ Branch 0 taken 3728 times.
✓ Branch 1 taken 466 times.
4194 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12740 {
12741
1/2
✓ Branch 0 taken 3728 times.
✗ Branch 1 not taken.
3728 if (globalscripts[i])
12742 3728 globalscripts[i]->disable();
12743 else
12744 globalscripts[i] = new script_data(ScriptType::Global, i);
12745 3728 }
12746
12747
2/2
✓ Branch 0 taken 2330 times.
✓ Branch 1 taken 466 times.
2796 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
12748 {
12749
1/2
✓ Branch 0 taken 2330 times.
✗ Branch 1 not taken.
2330 if (playerscripts[i])
12750 2330 playerscripts[i]->disable();
12751 else
12752 playerscripts[i] = new script_data(ScriptType::Hero, i);
12753 2330 }
12754
12755
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12756 {
12757
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (lwpnscripts[i])
12758 119296 lwpnscripts[i]->disable();
12759 else
12760 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12761 119296 }
12762
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12763 {
12764
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (ewpnscripts[i])
12765 119296 ewpnscripts[i]->disable();
12766 else
12767 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12768 119296 }
12769
12770
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12771 {
12772
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (dmapscripts[i])
12773 119296 dmapscripts[i]->disable();
12774 else
12775 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12776 119296 }
12777
2/2
✓ Branch 0 taken 119296 times.
✓ Branch 1 taken 466 times.
119762 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12778 {
12779
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (itemspritescripts[i])
12780 119296 itemspritescripts[i]->disable();
12781 else
12782 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12783 119296 }
12784
2/2
✓ Branch 0 taken 238592 times.
✓ Branch 1 taken 466 times.
239058 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12785 {
12786
1/2
✓ Branch 0 taken 238592 times.
✗ Branch 1 not taken.
238592 if (comboscripts[i])
12787 238592 comboscripts[i]->disable();
12788 else
12789 comboscripts[i] = new script_data(ScriptType::Combo, i);
12790 238592 }
12791
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 119296 times.
119762 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12792 {
12793
1/2
✓ Branch 0 taken 119296 times.
✗ Branch 1 not taken.
119296 if (subscreenscripts[i])
12794 119296 subscreenscripts[i]->disable();
12795 else
12796 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12797 119296 }
12798 466 }
12799
12800 // 3.0+ calls this.
12801 114 int32_t read_quest_zasm(PACKFILE *f, word s_version)
12802 {
12803 int32_t num_commands;
12804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_igetl(&num_commands,f))
12805 return qe_invalid;
12806 #ifdef ZC_FUZZ
12807 const int32_t command_limit = 300000;
12808 #else
12809 114 const int32_t command_limit = 25000000;
12810 #endif
12811
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 if (num_commands < 0 || num_commands > command_limit)
12812 return qe_invalid;
12813
12814 114 std::vector<ffscript> zasm;
12815
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 zasm.reserve(num_commands);
12816
2/2
✓ Branch 0 taken 2674541 times.
✓ Branch 1 taken 114 times.
2674655 for(int32_t j=0; j<num_commands; j++)
12817 {
12818
1/2
✓ Branch 0 taken 2674541 times.
✗ Branch 1 not taken.
2674541 ffscript temp_script;
12819
2/4
✓ Branch 0 taken 2674541 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2674541 times.
✗ Branch 3 not taken.
2674541 if(!p_igetw(&(temp_script.command),f))
12820 return qe_invalid;
12821
12822
2/4
✓ Branch 0 taken 2674541 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2674541 times.
✗ Branch 3 not taken.
2674541 if(!p_igetl(&(temp_script.arg1),f))
12823 return qe_invalid;
12824
12825
2/4
✓ Branch 0 taken 2674541 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2674541 times.
✗ Branch 3 not taken.
2674541 if(!p_igetl(&(temp_script.arg2),f))
12826 return qe_invalid;
12827
12828
2/4
✓ Branch 0 taken 2674541 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2674541 times.
✗ Branch 3 not taken.
2674541 if(!p_igetl(&(temp_script.arg3),f))
12829 return qe_invalid;
12830
12831 2674541 uint32_t sz = 0;
12832
2/4
✓ Branch 0 taken 2674541 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2674541 times.
✗ Branch 3 not taken.
2674541 if(!p_igetl(&sz,f))
12833 return qe_invalid;
12834
2/2
✓ Branch 0 taken 22294 times.
✓ Branch 1 taken 2652247 times.
2674541 if(sz) //string found
12835 {
12836
1/2
✓ Branch 0 taken 22294 times.
✗ Branch 1 not taken.
22294 temp_script.strptr = new std::string();
12837 char dummy;
12838
2/2
✓ Branch 0 taken 364751 times.
✓ Branch 1 taken 22294 times.
387045 for(size_t q = 0; q < sz; ++q)
12839 {
12840
2/4
✓ Branch 0 taken 364751 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 364751 times.
✗ Branch 3 not taken.
364751 if(!p_getc(&dummy,f))
12841 return qe_invalid;
12842
1/2
✓ Branch 0 taken 364751 times.
✗ Branch 1 not taken.
364751 temp_script.strptr->push_back(dummy);
12843 364751 }
12844 22294 }
12845
2/4
✓ Branch 0 taken 2674541 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2674541 times.
✗ Branch 3 not taken.
2674541 if(!p_igetl(&sz,f))
12846 return qe_invalid;
12847
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 2672549 times.
2674541 if(sz) //vector found
12848 {
12849
1/2
✓ Branch 0 taken 1992 times.
✗ Branch 1 not taken.
1992 temp_script.vecptr = new std::vector<int32_t>();
12850 int32_t dummy;
12851
2/2
✓ Branch 0 taken 6765 times.
✓ Branch 1 taken 1992 times.
8757 for(size_t q = 0; q < sz; ++q)
12852 {
12853
2/4
✓ Branch 0 taken 6765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6765 times.
✗ Branch 3 not taken.
6765 if(!p_igetl(&dummy,f))
12854 return qe_invalid;
12855
1/2
✓ Branch 0 taken 6765 times.
✗ Branch 1 not taken.
6765 temp_script.vecptr->push_back(dummy);
12856 6765 }
12857 1992 }
12858
1/2
✓ Branch 0 taken 2674541 times.
✗ Branch 1 not taken.
2674541 zasm.emplace_back(std::move(temp_script));
12859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2674541 times.
2674541 }
12860
12861
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 assert(zasm_scripts.empty());
12862 114 zasm_script_id id = zasm_scripts.size();
12863
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
114 zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, "@single", std::move(zasm)));
12864
12865 114 return 0;
12866 114 }
12867
12868 1003960 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, script_data *script, word zmeta_version)
12869 {
12870 ASSERT(script);
12871
2/2
✓ Branch 0 taken 564718 times.
✓ Branch 1 taken 439242 times.
1003960 if(s_version < 27)
12872 564718 return read_old_ffscript(f, script_index, s_version, script, zmeta_version);
12873
12874 char exists;
12875
1/2
✓ Branch 0 taken 439242 times.
✗ Branch 1 not taken.
439242 if (!p_getc(&exists, f))
12876 return qe_invalid;
12877
2/2
✓ Branch 0 taken 3154 times.
✓ Branch 1 taken 436088 times.
439242 if (!exists)
12878 {
12879 436088 script->disable();
12880 436088 return 0;
12881 }
12882
12883 //Read meta
12884 {
12885 3154 zasm_meta temp_meta;
12886
12887
2/4
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3154 times.
✗ Branch 3 not taken.
3154 if(!p_igetw(&(temp_meta.zasm_v),f))
12888 return qe_invalid;
12889
2/4
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3154 times.
✗ Branch 3 not taken.
3154 if(!p_igetw(&(temp_meta.meta_v),f))
12890 return qe_invalid;
12891
2/4
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3154 times.
✗ Branch 3 not taken.
3154 if(!p_igetw(&(temp_meta.ffscript_v),f))
12892 return qe_invalid;
12893
2/4
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3154 times.
✗ Branch 3 not taken.
3154 if(!p_getc(&(temp_meta.script_type),f))
12894 return qe_invalid;
12895
12896
2/2
✓ Branch 0 taken 25232 times.
✓ Branch 1 taken 3154 times.
28386 for(int32_t q = 0; q < 8; ++q)
12897 {
12898
2/4
✓ Branch 0 taken 25232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25232 times.
✗ Branch 3 not taken.
25232 if(!p_getcstr(&temp_meta.run_idens[q],f))
12899 return qe_invalid;
12900 25232 }
12901
12902
2/2
✓ Branch 0 taken 3154 times.
✓ Branch 1 taken 25232 times.
28386 for(int32_t q = 0; q < 8; ++q)
12903
2/4
✓ Branch 0 taken 25232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25232 times.
✗ Branch 3 not taken.
25232 if(!p_getc(&(temp_meta.run_types[q]),f))
12904 return qe_invalid;
12905
12906
2/4
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3154 times.
✗ Branch 3 not taken.
3154 if(!p_getc(&(temp_meta.flags),f))
12907 return qe_invalid;
12908
12909
2/4
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3154 times.
✗ Branch 3 not taken.
3154 if(!p_igetw(&(temp_meta.compiler_v1),f))
12910 return qe_invalid;
12911
2/4
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3154 times.
✗ Branch 3 not taken.
3154 if(!p_igetw(&(temp_meta.compiler_v2),f))
12912 return qe_invalid;
12913
2/4
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3154 times.
✗ Branch 3 not taken.
3154 if(!p_igetw(&(temp_meta.compiler_v3),f))
12914 return qe_invalid;
12915
2/4
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3154 times.
✗ Branch 3 not taken.
3154 if(!p_igetw(&(temp_meta.compiler_v4),f))
12916 return qe_invalid;
12917
12918
2/4
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3154 times.
✗ Branch 3 not taken.
3154 if(!p_getcstr(&temp_meta.script_name,f))
12919 return qe_invalid;
12920
2/4
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3154 times.
✗ Branch 3 not taken.
3154 if(!p_getcstr(&temp_meta.author,f))
12921 return qe_invalid;
12922 3154 auto num_meta_attrib = 10;
12923
2/2
✓ Branch 0 taken 31540 times.
✓ Branch 1 taken 3154 times.
34694 for(auto q = 0; q < num_meta_attrib; ++q)
12924 {
12925
2/4
✓ Branch 0 taken 31540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31540 times.
✗ Branch 3 not taken.
31540 if(!p_getcstr(&temp_meta.attributes[q],f))
12926 return qe_invalid;
12927
2/4
✓ Branch 0 taken 31540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31540 times.
✗ Branch 3 not taken.
31540 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12928 return qe_invalid;
12929 31540 }
12930
2/2
✓ Branch 0 taken 25232 times.
✓ Branch 1 taken 3154 times.
28386 for(auto q = 0; q < 8; ++q)
12931 {
12932
2/4
✓ Branch 0 taken 25232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25232 times.
✗ Branch 3 not taken.
25232 if(!p_getcstr(&temp_meta.attribytes[q],f))
12933 return qe_invalid;
12934
2/4
✓ Branch 0 taken 25232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25232 times.
✗ Branch 3 not taken.
25232 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12935 return qe_invalid;
12936 25232 }
12937
2/2
✓ Branch 0 taken 25232 times.
✓ Branch 1 taken 3154 times.
28386 for(auto q = 0; q < 8; ++q)
12938 {
12939
2/4
✓ Branch 0 taken 25232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25232 times.
✗ Branch 3 not taken.
25232 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12940 return qe_invalid;
12941
2/4
✓ Branch 0 taken 25232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25232 times.
✗ Branch 3 not taken.
25232 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12942 return qe_invalid;
12943 25232 }
12944
2/2
✓ Branch 0 taken 50464 times.
✓ Branch 1 taken 3154 times.
53618 for(auto q = 0; q < 16; ++q)
12945 {
12946
2/4
✓ Branch 0 taken 50464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50464 times.
✗ Branch 3 not taken.
50464 if(!p_getcstr(&temp_meta.usrflags[q],f))
12947 return qe_invalid;
12948
2/4
✓ Branch 0 taken 50464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50464 times.
✗ Branch 3 not taken.
50464 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12949 return qe_invalid;
12950 50464 }
12951
2/2
✓ Branch 0 taken 25232 times.
✓ Branch 1 taken 3154 times.
28386 for(auto q = 0; q < 8; ++q)
12952 {
12953
2/4
✓ Branch 0 taken 25232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25232 times.
✗ Branch 3 not taken.
25232 if(!p_getcstr(&temp_meta.initd[q],f))
12954 return qe_invalid;
12955
2/4
✓ Branch 0 taken 25232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25232 times.
✗ Branch 3 not taken.
25232 if(!p_getwstr(&temp_meta.initd_help[q],f))
12956 return qe_invalid;
12957 25232 }
12958
2/2
✓ Branch 0 taken 3154 times.
✓ Branch 1 taken 25232 times.
28386 for(auto q = 0; q < 8; ++q)
12959 {
12960
2/4
✓ Branch 0 taken 25232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25232 times.
✗ Branch 3 not taken.
25232 if(!p_getc(&temp_meta.initd_type[q],f))
12961 return qe_invalid;
12962 25232 }
12963
12964
1/2
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
3154 script->meta = temp_meta;
12965
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3154 times.
3154 }
12966
1/2
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
3154 if(!p_igetl(&script->pc, f))
12967 return qe_invalid;
12968
1/2
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
3154 if(!p_igetl(&script->end_pc, f))
12969 return qe_invalid;
12970
12971
1/2
✓ Branch 0 taken 3154 times.
✗ Branch 1 not taken.
3154 assert(zasm_scripts.size() == 1);
12972 3154 auto& zs = zasm_scripts[0];
12973 3154 script->zasm_script = zs;
12974
12975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3154 times.
3154 if (script->valid())
12976 {
12977 3154 zs->script_datas.push_back(script);
12978 3154 read_scripts.push_back(script);
12979 3154 }
12980
12981 3154 return 0;
12982 1003960 }
12983
12984 564718 int32_t read_old_ffscript(PACKFILE *f, int32_t script_index, word s_version, script_data *script, word zmeta_version)
12985 {
12986 564718 char b33[34] = {0};
12987 564718 b33[33] = 0;
12988 564718 int32_t num_commands=1000;
12989
12990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 564718 times.
564718 if(s_version>=2)
12991 {
12992
1/2
✓ Branch 0 taken 564718 times.
✗ Branch 1 not taken.
564718 if(!p_igetl(&num_commands,f))
12993 {
12994 return qe_invalid;
12995 }
12996 564718 }
12997
12998 #ifdef ZC_FUZZ
12999 const int32_t command_limit = 300000;
13000 #else
13001 564718 const int32_t command_limit = 10000000;
13002 #endif
13003
2/4
✓ Branch 0 taken 564718 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 564718 times.
564718 if (num_commands < 0 || num_commands > command_limit)
13004 {
13005 return qe_invalid;
13006 }
13007
13008 564718 std::vector<ffscript> zasm;
13009
1/2
✓ Branch 0 taken 564718 times.
✗ Branch 1 not taken.
564718 zasm.reserve(num_commands);
13010
13011
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 314772 times.
564718 if(s_version >= 16)
13012 {
13013
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 zasm_meta temp_meta;
13014
13015
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.zasm_v),f))
13016 {
13017 return qe_invalid;
13018 }
13019
13020
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.meta_v),f))
13021 {
13022 return qe_invalid;
13023 }
13024
13025
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.ffscript_v),f))
13026 {
13027 return qe_invalid;
13028 }
13029
13030
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.script_type),f))
13031 {
13032 return qe_invalid;
13033 }
13034
13035
2/2
✓ Branch 0 taken 1999568 times.
✓ Branch 1 taken 249946 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13036 {
13037
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 1855688 times.
1999568 if(zmeta_version < 3)
13038 {
13039
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
13040 {
13041
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
13042 {
13043 return qe_invalid;
13044 }
13045 4748040 }
13046
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
13047 143880 }
13048 else
13049 {
13050
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.run_idens[q],f))
13051 {
13052 return qe_invalid;
13053 }
13054 }
13055 1999568 }
13056
13057
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 1999568 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13058 {
13059
2/4
✓ Branch 0 taken 1999568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1999568 times.
✗ Branch 3 not taken.
1999568 if(!p_getc(&(temp_meta.run_types[q]),f))
13060 {
13061 return qe_invalid;
13062 }
13063 1999568 }
13064
13065
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.flags),f))
13066 {
13067 return qe_invalid;
13068 }
13069
13070
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v1),f))
13071 {
13072 return qe_invalid;
13073 }
13074
13075
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v2),f))
13076 {
13077 return qe_invalid;
13078 }
13079
13080
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v3),f))
13081 {
13082 return qe_invalid;
13083 }
13084
13085
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v4),f))
13086 {
13087 return qe_invalid;
13088 }
13089
13090
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 231961 times.
249946 if(zmeta_version == 2)
13091 {
13092
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13093 {
13094
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13095 {
13096 return qe_invalid;
13097 }
13098 593505 }
13099
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
13100
13101
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13102 {
13103
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13104 {
13105 return qe_invalid;
13106 }
13107 593505 }
13108
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
13109 17985 }
13110
1/2
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
231961 else if(zmeta_version > 2)
13111 {
13112
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.script_name,f))
13113 return qe_invalid;
13114
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.author,f))
13115 return qe_invalid;
13116 231961 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13117
2/2
✓ Branch 0 taken 2319610 times.
✓ Branch 1 taken 231961 times.
2551571 for(auto q = 0; q < num_meta_attrib; ++q)
13118 {
13119
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getcstr(&temp_meta.attributes[q],f))
13120 return qe_invalid;
13121
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13122 return qe_invalid;
13123 2319610 }
13124
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13125 {
13126
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attribytes[q],f))
13127 return qe_invalid;
13128
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13129 return qe_invalid;
13130 1855688 }
13131
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13132 {
13133
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13134 return qe_invalid;
13135
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13136 return qe_invalid;
13137 1855688 }
13138
2/2
✓ Branch 0 taken 3711376 times.
✓ Branch 1 taken 231961 times.
3943337 for(auto q = 0; q < 16; ++q)
13139 {
13140
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getcstr(&temp_meta.usrflags[q],f))
13141 return qe_invalid;
13142
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13143 return qe_invalid;
13144 3711376 }
13145 231961 }
13146
2/2
✓ Branch 0 taken 231961 times.
✓ Branch 1 taken 17985 times.
249946 if(zmeta_version > 3)
13147 {
13148
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13149 {
13150
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.initd[q],f))
13151 return qe_invalid;
13152
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.initd_help[q],f))
13153 return qe_invalid;
13154 1855688 }
13155
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13156 {
13157
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getc(&temp_meta.initd_type[q],f))
13158 return qe_invalid;
13159 1855688 }
13160 231961 }
13161 else
13162 {
13163
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
13164 {
13165
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
13166 143880 }
13167 }
13168
13169
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 script->meta = temp_meta;
13170
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 249946 times.
✓ Branch 2 taken 314772 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 314772 times.
✗ Branch 5 not taken.
564718 } else script->meta = {};
13171
13172
2/2
✓ Branch 0 taken 93815074 times.
✓ Branch 1 taken 74674 times.
93889748 for(int32_t j=0; j<num_commands; j++)
13173 {
13174
1/2
✓ Branch 0 taken 93815074 times.
✗ Branch 1 not taken.
93815074 auto& sc = zasm.emplace_back();
13175
2/4
✓ Branch 0 taken 93815074 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93815074 times.
✗ Branch 3 not taken.
93815074 if(!p_igetw(&sc.command,f))
13176 {
13177 return qe_invalid;
13178 }
13179
13180
2/2
✓ Branch 0 taken 93325030 times.
✓ Branch 1 taken 490044 times.
93815074 if(sc.command == 0xFFFF)
13181 490044 break;
13182 else
13183 {
13184
2/4
✓ Branch 0 taken 93325030 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93325030 times.
✗ Branch 3 not taken.
93325030 if(!p_igetl(&sc.arg1,f))
13185 {
13186 return qe_invalid;
13187 }
13188
13189
2/4
✓ Branch 0 taken 93325030 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93325030 times.
✗ Branch 3 not taken.
93325030 if(!p_igetl(&sc.arg2,f))
13190 {
13191 return qe_invalid;
13192 }
13193
13194
2/2
✓ Branch 0 taken 1047747 times.
✓ Branch 1 taken 92277283 times.
93325030 if(s_version >= 24)
13195
2/4
✓ Branch 0 taken 1047747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047747 times.
✗ Branch 3 not taken.
1047747 if(!p_igetl(&sc.arg3,f))
13196 return qe_invalid;
13197
13198
2/2
✓ Branch 0 taken 8222037 times.
✓ Branch 1 taken 85102993 times.
93325030 if(s_version >= 21)
13199 {
13200 8222037 uint32_t sz = 0;
13201
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13202 {
13203 return qe_invalid;
13204 }
13205
2/2
✓ Branch 0 taken 19400 times.
✓ Branch 1 taken 8202637 times.
8222037 if(sz) //string found
13206 {
13207
1/2
✓ Branch 0 taken 19400 times.
✗ Branch 1 not taken.
19400 sc.strptr = new std::string();
13208 char dummy;
13209
2/2
✓ Branch 0 taken 1165008 times.
✓ Branch 1 taken 19400 times.
1184408 for(size_t q = 0; q < sz; ++q)
13210 {
13211
2/4
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165008 times.
✗ Branch 3 not taken.
1165008 if(!p_getc(&dummy,f))
13212 {
13213 return qe_invalid;
13214 }
13215
1/2
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
1165008 sc.strptr->push_back(dummy);
13216 1165008 }
13217 19400 }
13218
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13219 {
13220 return qe_invalid;
13221 }
13222
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 8221104 times.
8222037 if(sz) //vector found
13223 {
13224
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 sc.vecptr = new std::vector<int32_t>();
13225 int32_t dummy;
13226
2/2
✓ Branch 0 taken 11526 times.
✓ Branch 1 taken 933 times.
12459 for(size_t q = 0; q < sz; ++q)
13227 {
13228
2/4
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11526 times.
✗ Branch 3 not taken.
11526 if(!p_igetl(&dummy,f))
13229 {
13230 return qe_invalid;
13231 }
13232
1/2
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
11526 sc.vecptr->push_back(dummy);
13233 11526 }
13234 933 }
13235 8222037 }
13236 }
13237 93325030 }
13238
13239 // If the first command is unknown, invalidate the whole thing.
13240 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13241
5/6
✓ Branch 0 taken 490044 times.
✓ Branch 1 taken 74674 times.
✓ Branch 2 taken 478356 times.
✓ Branch 3 taken 11688 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 478356 times.
564718 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13242 {
13243 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString(script->id.type), script->id.index);
13244 zasm.clear();
13245 }
13246
13247 564718 zasm_script_id id = zasm_scripts.size();
13248
3/6
✓ Branch 0 taken 564718 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 564718 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 564718 times.
✗ Branch 5 not taken.
564718 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, script->name(), std::move(zasm)));
13249 564718 script->zasm_script = zs;
13250 564718 script->pc = 0;
13251 564718 script->end_pc = zs->size;
13252
3/4
✓ Branch 0 taken 564718 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11688 times.
✓ Branch 3 taken 553030 times.
564718 if (script->valid())
13253 {
13254
1/2
✓ Branch 0 taken 11688 times.
✗ Branch 1 not taken.
11688 zs->script_datas.push_back(script);
13255
1/2
✓ Branch 0 taken 11688 times.
✗ Branch 1 not taken.
11688 read_scripts.push_back(script);
13256 11688 }
13257
13258 564718 return 0;
13259 564718 }
13260
13261 extern SAMPLE customsfxdata[WAV_COUNT];
13262 extern uint8_t customsfxflag[WAV_COUNT>>3];
13263 extern int32_t sfxdat;
13264 extern DATAFILE *sfxdata;
13265 const char *old_sfx_string[Z35] =
13266 {
13267 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13268 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13269 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13270 "Hookshot", "Message", "Hero is hit", "Item fanfare", "Bomb placed", "Item pickup",
13271 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13272 "Secret chime", "Hero dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13273 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13274 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13275 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13276 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13277 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13278 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13279 };
13280 char *sfx_string[WAV_COUNT];
13281
13282 384 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13283 {
13284 //these are here to bypass compiler warnings about unused arguments
13285 384 Header=Header;
13286
13287 int32_t dummy;
13288 384 word s_version=0;
13289 //int32_t ret;
13290 384 SAMPLE temp_sample = {};
13291 384 temp_sample.loop_start=0;
13292 384 temp_sample.loop_end=0;
13293 384 temp_sample.param=0;
13294
13295 //section version info
13296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_igetw(&s_version,f))
13297 {
13298 return qe_invalid;
13299 }
13300
13301 384 FFCore.quest_format[vSFX] = s_version;
13302
13303
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
13304 {
13305 return qe_invalid;
13306 }
13307
13308 //section size
13309
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&dummy,f))
13310 {
13311 return qe_invalid;
13312 }
13313
13314 /* HIGHLY UNORTHODOX UPDATING THING, by L
13315 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13316 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13317 * changing from 1 to 2.
13318 */
13319
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(s_version < 2)
13320 set_qr(qr_GOTOLESSNOTEQUAL,1);
13321
13322 /* End highly unorthodox updating thing */
13323
13324 384 int32_t wavcount = WAV_COUNT;
13325
13326
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(s_version < 6)
13327 wavcount = 128;
13328
13329 uint8_t tempflag[WAV_COUNT>>3];
13330
13331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(s_version < 4)
13332 {
13333 memset(tempflag, 0xFF, WAV_COUNT>>3);
13334 }
13335 else
13336 {
13337
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(s_version < 6)
13338 memset(tempflag, 0, WAV_COUNT>>3);
13339
13340
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 384 times.
12672 for(int32_t i=0; i<(wavcount>>3); i++)
13341 {
13342 12288 p_getc(&tempflag[i], f);
13343 12288 }
13344
13345 }
13346
13347
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(s_version>4)
13348 {
13349
2/2
✓ Branch 0 taken 97920 times.
✓ Branch 1 taken 384 times.
98304 for(int32_t i=1; i<WAV_COUNT; i++)
13350 {
13351 97920 sprintf(sfx_string[i],"s%03d",i);
13352
13353
2/2
✓ Branch 0 taken 74880 times.
✓ Branch 1 taken 23040 times.
97920 if((i<Z35))
13354 23040 strcpy(sfx_string[i], old_sfx_string[i-1]);
13355
13356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97920 times.
97920 if(i>=wavcount)
13357 continue;
13358
2/2
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 78388 times.
97920 if(get_bit(tempflag, i-1))
13359 {
13360 char tempname[36];
13361
13362
1/2
✓ Branch 0 taken 19532 times.
✗ Branch 1 not taken.
19532 if(!pfread(tempname, 36, f))
13363 {
13364 return qe_invalid;
13365 }
13366
13367 19532 sfx_string[i][0] = '\0';
13368 19532 strncat(sfx_string[i], tempname, 36 - 1);
13369 19532 }
13370 else
13371 {
13372 78388 sprintf(sfx_string[i],"s%03d",i);
13373
13374
2/2
✓ Branch 0 taken 68523 times.
✓ Branch 1 taken 9865 times.
78388 if(i<Z35)
13375 9865 strcpy(sfx_string[i], old_sfx_string[i-1]);
13376 78388 sfx_string[i][35] = 0; //Force NULL Termination
13377 }
13378 97920 }
13379 384 }
13380 else
13381 {
13382 for(int32_t i=1; i<WAV_COUNT; i++)
13383 {
13384 sprintf(sfx_string[i],"s%03d",i);
13385
13386 if(i<Z35)
13387 strcpy(sfx_string[i], old_sfx_string[i-1]);
13388 }
13389 }
13390
13391 //finally... section data
13392
2/2
✓ Branch 0 taken 97920 times.
✓ Branch 1 taken 384 times.
98304 for(int32_t i=1; i<wavcount; i++)
13393 {
13394
2/2
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 78388 times.
97920 if(get_bit(tempflag, i-1))
13395 {
13396
13397
1/2
✓ Branch 0 taken 19532 times.
✗ Branch 1 not taken.
19532 if(!p_igetl(&dummy,f))
13398 {
13399 return qe_invalid;
13400 }
13401
13402 19532 (temp_sample.bits) = dummy;
13403
13404
1/2
✓ Branch 0 taken 19532 times.
✗ Branch 1 not taken.
19532 if(!p_igetl(&dummy,f))
13405 {
13406 return qe_invalid;
13407 }
13408
13409 19532 (temp_sample.stereo) = dummy;
13410
13411
1/2
✓ Branch 0 taken 19532 times.
✗ Branch 1 not taken.
19532 if(!p_igetl(&dummy,f))
13412 {
13413 return qe_invalid;
13414 }
13415
13416 19532 (temp_sample.freq) = dummy;
13417
13418
1/2
✓ Branch 0 taken 19532 times.
✗ Branch 1 not taken.
19532 if(!p_igetl(&dummy,f))
13419 {
13420 return qe_invalid;
13421 }
13422
13423 19532 (temp_sample.priority) = dummy;
13424
13425
1/2
✓ Branch 0 taken 19532 times.
✗ Branch 1 not taken.
19532 if(!p_igetl(&(temp_sample.len),f))
13426 {
13427 return qe_invalid;
13428 }
13429
13430
1/2
✓ Branch 0 taken 19532 times.
✗ Branch 1 not taken.
19532 if(!p_igetl(&(temp_sample.loop_start),f))
13431 {
13432 return qe_invalid;
13433 }
13434
13435
1/2
✓ Branch 0 taken 19532 times.
✗ Branch 1 not taken.
19532 if(!p_igetl(&(temp_sample.loop_end),f))
13436 {
13437 return qe_invalid;
13438 }
13439
13440
1/2
✓ Branch 0 taken 19532 times.
✗ Branch 1 not taken.
19532 if(!p_igetl(&(temp_sample.param),f))
13441 {
13442 return qe_invalid;
13443 }
13444
13445 19532 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13446 #ifdef ZC_FUZZ
13447 const int32_t sfx_limit = 100000;
13448 if (len < 0 || len > sfx_limit)
13449 {
13450 return qe_invalid;
13451 }
13452 #endif
13453 19532 temp_sample.data = calloc(len,1);
13454
13455
1/2
✓ Branch 0 taken 19532 times.
✗ Branch 1 not taken.
19532 if(s_version < 3)
13456 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13457
13458 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19532 times.
19532 if(s_version < 2)
13460 {
13461 if(!pfread(temp_sample.data, len,f))
13462 {
13463 return qe_invalid;
13464 }
13465 }
13466 else
13467 {
13468 //re-endianfy the data
13469 19532 int32_t wordstoread = len / sizeof(word);
13470
13471
2/2
✓ Branch 0 taken 538690852 times.
✓ Branch 1 taken 19532 times.
538710384 for(int32_t j=0; j<wordstoread; j++)
13472 {
13473 word temp;
13474
13475
1/2
✓ Branch 0 taken 538690852 times.
✗ Branch 1 not taken.
538690852 if(!p_igetw(&temp, f))
13476 {
13477 return qe_invalid;
13478 }
13479
13480 538690852 ((word *)temp_sample.data)[j] = temp;
13481 538690852 }
13482 }
13483 19532 }
13484
2/2
✓ Branch 0 taken 9865 times.
✓ Branch 1 taken 68523 times.
78388 else if(i < Z35)
13485 {
13486 9865 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13487 9865 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13488 9865 set_bit(tempflag, i-1, 1);
13489 9865 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13490 9865 temp_sample.data = calloc(len,1);
13491 9865 memcpy(temp_sample.data, datsamp->data, len);
13492 9865 }
13493 68523 else continue;
13494
13495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29397 times.
29397 if(customsfxdata[i].data!=NULL)
13496 {
13497 // delete [] customsfxdata[i].data;
13498 29397 free(customsfxdata[i].data);
13499 29397 }
13500
13501 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13502 29397 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13503 29397 customsfxdata[i].data = calloc(len2,1);
13504 29397 customsfxdata[i].bits = temp_sample.bits;
13505 29397 customsfxdata[i].stereo = temp_sample.stereo;
13506 29397 customsfxdata[i].freq = temp_sample.freq;
13507 29397 customsfxdata[i].priority = temp_sample.priority;
13508 29397 customsfxdata[i].len = temp_sample.len;
13509 29397 customsfxdata[i].loop_start = temp_sample.loop_start;
13510 29397 customsfxdata[i].loop_end = temp_sample.loop_end;
13511 29397 customsfxdata[i].param = temp_sample.param;
13512 29397 int32_t cpylen = len2;
13513
13514
1/2
✓ Branch 0 taken 29397 times.
✗ Branch 1 not taken.
29397 if(s_version<3)
13515 {
13516 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13517 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13518 }
13519
13520 29397 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13521
13522 29397 free(temp_sample.data);
13523 29397 }
13524
13525 384 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13526
13527 384 sfxdat=0;
13528 384 return 0;
13529 384 }
13530
13531 466 void setupsfx()
13532 {
13533
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=1; i<WAV_COUNT; i++)
13534 {
13535 118830 sprintf(sfx_string[i],"s%03d",i);
13536
13537
2/2
✓ Branch 0 taken 90870 times.
✓ Branch 1 taken 27960 times.
118830 if(i<Z35)
13538 {
13539 27960 strcpy(sfx_string[i], old_sfx_string[i-1]);
13540 27960 }
13541
13542 118830 memset(customsfxflag, 0, WAV_COUNT>>3);
13543
13544 118830 int32_t j=i;
13545
13546
2/2
✓ Branch 0 taken 28426 times.
✓ Branch 1 taken 90404 times.
118830 if(i>Z35)
13547 {
13548 90404 i=Z35;
13549 90404 }
13550
13551 118830 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13552
13553
2/2
✓ Branch 0 taken 91290 times.
✓ Branch 1 taken 27540 times.
118830 if(customsfxdata[j].data!=NULL)
13554 {
13555 // delete [] customsfxdata[j].data;
13556 27540 free(customsfxdata[j].data);
13557 27540 }
13558
13559 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13560 118830 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13561 118830 customsfxdata[j].bits = temp_sample->bits;
13562 118830 customsfxdata[j].stereo = temp_sample->stereo;
13563 118830 customsfxdata[j].freq = temp_sample->freq;
13564 118830 customsfxdata[j].priority = temp_sample->priority;
13565 118830 customsfxdata[j].len = temp_sample->len;
13566 118830 customsfxdata[j].loop_start = temp_sample->loop_start;
13567 118830 customsfxdata[j].loop_end = temp_sample->loop_end;
13568 118830 customsfxdata[j].param = temp_sample->param;
13569 118830 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13570 118830 i=j;
13571 118830 }
13572 466 }
13573
13574 extern char *guy_string[eMAXGUYS];
13575 extern const char *old_guy_string[OLDMAXGUYS];
13576
13577 466 int32_t readguys(PACKFILE *f, zquestheader *Header)
13578 {
13579
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
466 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if (should_skip) return 0;
13581
13582 dword dummy;
13583 word guy_cversion;
13584 466 word guyversion=0;
13585
13586
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 443 times.
466 if(Header->zelda_version >= 0x193)
13587 {
13588 //section version info
13589
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&guyversion,f))
13590 {
13591 return qe_invalid;
13592 }
13593
13594 443 FFCore.quest_format[vGuys] = guyversion;
13595
13596 // Note: this is the only instance where "cversion" is ever used.
13597
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&guy_cversion,f))
13598 {
13599 return qe_invalid;
13600 }
13601
13602 //section size
13603
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetl(&dummy,f))
13604 {
13605 return qe_invalid;
13606 }
13607 443 }
13608
13609
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
466 if(guyversion > 3)
13610 {
13611
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 384 times.
196992 for(int32_t i=0; i<MAXGUYS; i++)
13612 {
13613 char tempname[64];
13614
13615 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13616 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13617
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 196608 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
196608 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13618 {
13619 memset(tempname, 0, sizeof(char)*64);
13620 sprintf(tempname, "e%03d", i);
13621 strcpy(guy_string[i], tempname);
13622
13623 continue;
13624 }
13625
13626
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!pfread(tempname, 64, f))
13627 {
13628 return qe_invalid;
13629 }
13630
13631 // Don't retain names of uneditable enemy entries!
13632 // for version upgrade to 2.5
13633
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 196608 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
196608 if(guyversion < 23 && i >= 177)
13634 {
13635 // some of the older builds have names such as 'zz123',
13636 // (this order gets messed up with some eXXX and some zzXXX)
13637 // so let's update to the newer naming convection. -Gleeok
13638 char tmpbuf[64];
13639 memset(tmpbuf, 0, sizeof(char)*64);
13640 sprintf(tmpbuf, "zz%03d", i);
13641
13642 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13643 {
13644 memset(tempname, 0, sizeof(char)*64);
13645 sprintf(tempname, "e%03d", i);
13646 }
13647 }
13648
13649
6/6
✓ Branch 0 taken 67968 times.
✓ Branch 1 taken 128640 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3456 times.
✓ Branch 4 taken 55889 times.
✓ Branch 5 taken 8623 times.
196608 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13650 {
13651 187985 guy_string[i][0] = '\0';
13652 187985 strncat(guy_string[i], tempname, 64 - 1);
13653 187985 }
13654 else
13655 {
13656 8623 strcpy(guy_string[i],old_guy_string[i]);
13657 }
13658 196608 }
13659 384 }
13660 else
13661 {
13662
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13663 {
13664 41984 sprintf(guy_string[i],"zz%03d",i);
13665 41984 }
13666
13667
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13668 {
13669 14514 strcpy(guy_string[i],old_guy_string[i]);
13670 14514 }
13671 }
13672
13673
13674 //finally... section data
13675 466 init_guys(guyversion); //using default data for now...
13676
13677 // Goriya guy fix
13678
3/6
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
466 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13679 {
13680
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13681 {
13682 60 guysbuf[gGORIYA].tile=130;
13683 60 guysbuf[gGORIYA].e_tile=130;
13684 60 }
13685 82 }
13686
13687
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
466 if(Header->zelda_version < 0x193)
13688 {
13689
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13690 {
13691 5 guysbuf[eDODONGO].cset=14;
13692 5 guysbuf[eDODONGO].bosspal=spDIG;
13693 5 }
13694 23 }
13695 // Not sure when this first changed, but it's necessary for 2.10, at least
13696 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13697 //2.10 Fixes
13698
3/6
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
466 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13699 {
13700 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13701 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13702 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13703 82 guysbuf[eCENT1].attributes[2] = 1;
13704 82 guysbuf[eCENT2].attributes[2] = 1;
13705 82 }
13706
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
466 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13707 {
13708 466 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13709 466 }
13710
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
466 if(Header->zelda_version <= 0x210)
13711 {
13712 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
13713 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
13714 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
13715 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
13716
13717 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
13718 82 guysbuf[eBATROBE].attributes[3] = 1;
13719 //guysbuf[eSUMMONER].misc4 = 1;
13720 82 guysbuf[eWWIZ].attributes[3] = 1;
13721 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13722 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13723 82 }
13724
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 12 times.
466 if(Header->zelda_version == 0x190)
13725 {
13726 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13727 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13728 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13729 12 }
13730
13731 // The versions here may not be correct
13732 // zelda_version>=0x211 handled at guyversion<24
13733
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 448 times.
466 if(Header->zelda_version <= 0x190)
13734 {
13735 18 guysbuf[eCENT1].attributes[2] = 0;
13736 18 guysbuf[eCENT2].attributes[2] = 0;
13737 18 guysbuf[eMOLDORM].attributes[1] = 0;
13738 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13739 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13740 18 }
13741
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 64 times.
448 else if(Header->zelda_version <= 0x210)
13742 {
13743 64 guysbuf[eCENT1].attributes[2] = 1;
13744 64 guysbuf[eCENT2].attributes[2] = 1;
13745 64 guysbuf[eMOLDORM].attributes[1] = 0;
13746 64 }
13747
13748
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 82 times.
466 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13749 {
13750 82 guysbuf[eKEESE1].attributes[15] = 120;
13751 82 guysbuf[eKEESE2].attributes[15] = 120;
13752 82 guysbuf[eKEESE3].attributes[15] = 120;
13753 82 guysbuf[eKEESETRIB].attributes[15] = 120;
13754 82 guysbuf[eKEESE1].attributes[16] = 16;
13755 82 guysbuf[eKEESE2].attributes[16] = 16;
13756 82 guysbuf[eKEESE3].attributes[16] = 16;
13757 82 guysbuf[eKEESETRIB].attributes[16] = 16;
13758
13759 82 guysbuf[ePEAHAT].attributes[15] = 80;
13760 82 guysbuf[ePEAHAT].attributes[16] = 16;
13761
13762 82 guysbuf[eGHINI2].attributes[15] = 120;
13763 82 guysbuf[eGHINI2].attributes[16] = 10;
13764
13765
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13766 {
13767 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13768 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13769 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13770 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13771 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13772 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13773 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13774 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13775 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13776 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13777 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13778 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13779 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13780 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13781 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13782 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13783 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13784 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13785 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13786 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13787 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13788 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13789 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13790 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13791 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13792 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13793 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13794 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13795 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13796 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13797 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13798 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13799 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13800 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13801 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13802 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13803 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13804 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13805 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13806 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13807 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13808 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13809 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13810 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13811 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13812 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13813 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13814 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13815 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13816 66 }
13817 82 }
13818
13819
13820
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 384 times.
466 if(guyversion<=2)
13821 {
13822 82 return readherosprites2(f, guyversion==2?0:-1);
13823 }
13824
13825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(guyversion > 3)
13826 {
13827 guydata tempguy;
13828
13829
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 384 times.
196992 for(int32_t i=0; i<MAXGUYS; i++)
13830 {
13831
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 23) // May 2012 : 512 max enemies
13832 {
13833 if(i >= OLDBETAMAXGUYS)
13834 {
13835 memset(&guysbuf[i], 0, sizeof(guydata));
13836 continue;
13837 }
13838 }
13839
13840 196608 memset(&tempguy, 0, sizeof(guydata));
13841
13842 uint32_t flags1;
13843 uint32_t flags2;
13844
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetl(&(flags1),f))
13845 {
13846 return qe_invalid;
13847 }
13848
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetl(&(flags2),f))
13849 {
13850 return qe_invalid;
13851 }
13852 196608 tempguy.flags = guy_flags(flags1) | guy_flags(uint64_t(flags2)<<32ULL);
13853
13854
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if ( guyversion >= 36 ) //expanded tiles
13855 {
13856
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.tile),f))
13857 {
13858 return qe_invalid;
13859 }
13860 92160 }
13861 else
13862 {
13863
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_igetw(&(tempguy.tile),f))
13864 {
13865 return qe_invalid;
13866 }
13867 }
13868
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.width),f))
13869 {
13870 return qe_invalid;
13871 }
13872
13873
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.height),f))
13874 {
13875 return qe_invalid;
13876 }
13877
13878
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if ( guyversion >= 36 ) //expanded tiles
13879 {
13880
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.s_tile),f))
13881 {
13882 return qe_invalid;
13883 }
13884 92160 }
13885 else
13886 {
13887
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_igetw(&(tempguy.s_tile),f))
13888 {
13889 return qe_invalid;
13890 }
13891 }
13892
13893
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.s_width),f))
13894 {
13895 return qe_invalid;
13896 }
13897
13898
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.s_height),f))
13899 {
13900 return qe_invalid;
13901 }
13902
13903
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if ( guyversion >= 36 ) //expanded tiles
13904 {
13905
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.e_tile),f))
13906 {
13907 return qe_invalid;
13908 }
13909 92160 }
13910 else
13911 {
13912
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_igetw(&(tempguy.e_tile),f))
13913 {
13914 return qe_invalid;
13915 }
13916 }
13917
13918
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.e_width),f))
13919 {
13920 return qe_invalid;
13921 }
13922
13923
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.e_height),f))
13924 {
13925 return qe_invalid;
13926 }
13927
13928
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.hp),f))
13929 {
13930 return qe_invalid;
13931 }
13932
13933
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.family),f))
13934 {
13935 return qe_invalid;
13936 }
13937
13938
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 196608 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
196608 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13939 {
13940 if(get_qr(qr_NEWENEMYTILES))
13941 {
13942 tempguy.s_tile=tempguy.e_tile+120;
13943 tempguy.s_width=tempguy.e_width;
13944 tempguy.s_height=tempguy.e_height;
13945 }
13946 else tempguy.s_tile=860;
13947 }
13948
13949
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.cset),f))
13950 {
13951 return qe_invalid;
13952 }
13953
13954
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.anim),f))
13955 {
13956 return qe_invalid;
13957 }
13958
13959
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.e_anim),f))
13960 {
13961 return qe_invalid;
13962 }
13963
13964
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.frate),f))
13965 {
13966 return qe_invalid;
13967 }
13968
13969
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.e_frate),f))
13970 {
13971 return qe_invalid;
13972 }
13973
13974
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 13) // April 2009
13975 {
13976 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13977 {
13978 tempguy.frate *= 2;
13979 tempguy.e_frate *= 2;
13980 }
13981 }
13982
13983
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 14) // May 1 2009
13984 {
13985 if(tempguy.anim==a2FRMSLOW)
13986 {
13987 tempguy.anim=a2FRM;
13988 tempguy.frate *= 2;
13989 }
13990
13991 if(tempguy.e_anim==a2FRMSLOW)
13992 {
13993 tempguy.e_anim=a2FRM;
13994 tempguy.e_frate *= 2;
13995 }
13996
13997 if(tempguy.anim==aFLIPSLOW)
13998 {
13999 tempguy.anim=aFLIP;
14000 tempguy.frate *= 2;
14001 }
14002
14003 if(tempguy.e_anim==aFLIPSLOW)
14004 {
14005 tempguy.e_anim=aFLIP;
14006 tempguy.e_frate *= 2;
14007 }
14008
14009 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14010
14011 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14012
14013 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14014 {
14015 tempguy.anim=a4FRM4DIR;
14016 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14017 }
14018
14019 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14020 {
14021 tempguy.e_anim=a4FRM4DIR;
14022 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14023 }
14024 }
14025
14026
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.dp),f))
14027 {
14028 return qe_invalid;
14029 }
14030
14031 //correction for guy fire
14032
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 6)
14033 {
14034 if(i == gFIRE)
14035 tempguy.dp = 2;
14036 }
14037
14038
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.wdp),f))
14039 {
14040 return qe_invalid;
14041 }
14042
14043
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.weapon),f))
14044 {
14045 return qe_invalid;
14046 }
14047
14048 //correction for bosses using triple, "rising" fireballs
14049
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 5)
14050 {
14051 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14052 i == eGOHMA3 || i == eGOHMA4)
14053 {
14054 if(tempguy.weapon == ewFireball)
14055 tempguy.weapon = ewFireball2;
14056 }
14057 }
14058
14059
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.rate),f))
14060 {
14061 return qe_invalid;
14062 }
14063
14064
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.hrate),f))
14065 {
14066 return qe_invalid;
14067 }
14068
14069
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.step),f))
14070 {
14071 return qe_invalid;
14072 }
14073
14074 // HIGHLY UNORTHODOX UPDATING THING, part 2
14075
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 196608 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
196608 if(fixpolsvoice && tempguy.family==eePOLSV)
14076 {
14077 tempguy.step /= 2;
14078 }
14079
14080
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.homing),f))
14081 {
14082 return qe_invalid;
14083 }
14084
14085
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.grumble),f))
14086 {
14087 return qe_invalid;
14088 }
14089
14090
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.item_set),f))
14091 {
14092 return qe_invalid;
14093 }
14094
14095
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14096 {
14097
2/2
✓ Branch 0 taken 1966080 times.
✓ Branch 1 taken 196608 times.
2162688 for (int q = 0; q < 10; ++q)
14098 {
14099
1/2
✓ Branch 0 taken 1966080 times.
✗ Branch 1 not taken.
1966080 if (!p_igetl(&(tempguy.attributes[q]), f))
14100 {
14101 return qe_invalid;
14102 }
14103 1966080 }
14104 196608 }
14105 else
14106 {
14107 int16_t tempMisc;
14108
14109 for(int q=0;q<10;q++)
14110 {
14111 if (!p_igetw(&tempMisc, f))
14112 {
14113 return qe_invalid;
14114 }
14115 tempguy.attributes[q] = tempMisc;
14116 }
14117
14118 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14119 {
14120 if(tempguy.family == eeWIZZ && !(tempguy.attributes[0]))
14121 tempguy.attributes[4] = 74;
14122 }
14123
14124 }
14125
14126
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.bgsfx),f))
14127 {
14128 return qe_invalid;
14129 }
14130
14131
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.bosspal),f))
14132 {
14133 return qe_invalid;
14134 }
14135
14136
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetw(&(tempguy.extend),f))
14137 {
14138 return qe_invalid;
14139 }
14140
14141 //! Enemy Defences
14142
14143 //If a 2.50 quest, use only the 2.5 defences.
14144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196608 times.
196608 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14145 {
14146
2/2
✓ Branch 0 taken 3735552 times.
✓ Branch 1 taken 196608 times.
3932160 for(int32_t j=0; j<edefLAST; j++)
14147 {
14148
1/2
✓ Branch 0 taken 3735552 times.
✗ Branch 1 not taken.
3735552 if(!p_getc(&(tempguy.defense[j]),f))
14149 {
14150 return qe_invalid;
14151 }
14152 3735552 }
14153 //then copy the generic script defence to all the new script defences
14154
14155 196608 }
14156
14157
14158
14159
14160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196608 times.
196608 if(guyversion >= 18)
14161 {
14162
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.hitsfx),f))
14163 {
14164 return qe_invalid;
14165 }
14166
14167
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_getc(&(tempguy.deadsfx),f))
14168 {
14169 return qe_invalid;
14170 }
14171 196608 }
14172
14173
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion >= 22)
14174 {
14175
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetl(&(tempguy.attributes[10]), f))
14176 {
14177 return qe_invalid;
14178 }
14179
14180
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetl(&(tempguy.attributes[11]),f))
14181 {
14182 return qe_invalid;
14183 }
14184 196608 }
14185 else if(guyversion >= 19)
14186 {
14187 int16_t tempMisc;
14188
14189 if(!p_igetw(&tempMisc,f))
14190 {
14191 return qe_invalid;
14192 }
14193
14194 tempguy.attributes[10] = tempMisc;
14195
14196 if(!p_igetw(&tempMisc,f))
14197 {
14198 return qe_invalid;
14199 }
14200
14201 tempguy.attributes[11] = tempMisc;
14202 }
14203
14204 //If a 2.54 or later quest, use all of the defences.
14205
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 92160 times.
196608 if(guyversion > 24) // Add new guyversion conditional statement
14206 {
14207
2/2
✓ Branch 0 taken 2027520 times.
✓ Branch 1 taken 92160 times.
2119680 for(int32_t j=edefLAST; j<edefLAST255; j++)
14208 {
14209
1/2
✓ Branch 0 taken 2027520 times.
✗ Branch 1 not taken.
2027520 if(!p_getc(&(tempguy.defense[j]),f))
14210 {
14211 return qe_invalid;
14212 }
14213 2027520 }
14214 92160 }
14215
14216
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14217 {
14218
2/2
✓ Branch 0 taken 1044480 times.
✓ Branch 1 taken 104448 times.
1148928 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14219 {
14220 1044480 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14221 1044480 }
14222 104448 }
14223
14224 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14225
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 92160 times.
196608 if(guyversion > 25)
14226 {
14227
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.txsz),f))
14228 {
14229 return qe_invalid;
14230 }
14231
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.tysz),f))
14232 {
14233 return qe_invalid;
14234 }
14235
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.hxsz),f))
14236 {
14237 return qe_invalid;
14238 }
14239
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.hysz),f))
14240 {
14241 return qe_invalid;
14242 }
14243
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.hzsz),f))
14244 {
14245 return qe_invalid;
14246 }
14247 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14248
14249 */
14250 92160 }
14251 //More Enemy Editor vars for 2.60
14252
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 92160 times.
196608 if(guyversion > 26)
14253 {
14254
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.hxofs),f))
14255 {
14256 return qe_invalid;
14257 }
14258
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.hyofs),f))
14259 {
14260 return qe_invalid;
14261 }
14262
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.xofs),f))
14263 {
14264 return qe_invalid;
14265 }
14266
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.yofs),f))
14267 {
14268 return qe_invalid;
14269 }
14270
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.zofs),f))
14271 {
14272 return qe_invalid;
14273 }
14274 92160 }
14275
14276
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14277 {
14278 104448 tempguy.wpnsprite = 0;
14279 104448 }
14280
14281
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 92160 times.
196608 if(guyversion > 27)
14282 {
14283
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.wpnsprite),f))
14284 {
14285 return qe_invalid;
14286 }
14287 92160 }
14288
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14289 {
14290 104448 tempguy.SIZEflags = 0;
14291 104448 }
14292
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 92160 times.
196608 if(guyversion > 28)
14293 {
14294
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.SIZEflags),f))
14295 {
14296 return qe_invalid;
14297 }
14298
14299 92160 }
14300
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14301 {
14302 104448 tempguy.frozentile = 0;
14303 104448 tempguy.frozencset = 0;
14304 104448 tempguy.frozenclock = 0;
14305
2/2
✓ Branch 0 taken 1044480 times.
✓ Branch 1 taken 104448 times.
1148928 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14306 104448 }
14307
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 92160 times.
196608 if(guyversion >= 30)
14308 {
14309
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.frozentile),f))
14310 {
14311 return qe_invalid;
14312 }
14313
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.frozencset),f))
14314 {
14315 return qe_invalid;
14316 }
14317
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.frozenclock),f))
14318 {
14319 return qe_invalid;
14320 }
14321
2/2
✓ Branch 0 taken 921600 times.
✓ Branch 1 taken 92160 times.
1013760 for ( int32_t q = 0; q < 10; q++ ) {
14322
1/2
✓ Branch 0 taken 921600 times.
✗ Branch 1 not taken.
921600 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14323 {
14324 return qe_invalid;
14325 }
14326 921600 }
14327
14328 92160 }
14329
14330
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 92160 times.
196608 if(guyversion >= 34)
14331 {
14332
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetw(&(tempguy.firesfx),f))
14333 {
14334 return qe_invalid;
14335 }
14336
2/2
✓ Branch 0 taken 1566720 times.
✓ Branch 1 taken 92160 times.
1658880 for(int q=15;q<32;++q)
14337 {
14338
1/2
✓ Branch 0 taken 1566720 times.
✗ Branch 1 not taken.
1566720 if(!p_igetl(&(tempguy.attributes[q]),f))
14339 {
14340 return qe_invalid;
14341 }
14342 1566720 }
14343
14344
2/2
✓ Branch 0 taken 2949120 times.
✓ Branch 1 taken 92160 times.
3041280 for ( int32_t q = 0; q < 32; q++ ) {
14345
1/2
✓ Branch 0 taken 2949120 times.
✗ Branch 1 not taken.
2949120 if(!p_igetl(&(tempguy.movement[q]),f))
14346 {
14347 return qe_invalid;
14348 }
14349 2949120 }
14350
2/2
✓ Branch 0 taken 2949120 times.
✓ Branch 1 taken 92160 times.
3041280 for ( int32_t q = 0; q < 32; q++ ) {
14351
1/2
✓ Branch 0 taken 2949120 times.
✗ Branch 1 not taken.
2949120 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14352 {
14353 return qe_invalid;
14354 }
14355 2949120 }
14356
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetw(&(tempguy.script),f))
14357 {
14358 return qe_invalid;
14359 }
14360
2/2
✓ Branch 0 taken 737280 times.
✓ Branch 1 taken 92160 times.
829440 for ( int32_t q = 0; q < 8; q++ )
14361 {
14362
1/2
✓ Branch 0 taken 737280 times.
✗ Branch 1 not taken.
737280 if(!p_igetl(&(tempguy.initD[q]),f))
14363 {
14364 return qe_invalid;
14365 }
14366 737280 }
14367
2/2
✓ Branch 0 taken 184320 times.
✓ Branch 1 taken 92160 times.
276480 for ( int32_t q = 0; q < 2; q++ )
14368 {
14369 int32_t temp;
14370
1/2
✓ Branch 0 taken 184320 times.
✗ Branch 1 not taken.
184320 if(!p_igetl(&temp,f))
14371 {
14372 return qe_invalid;
14373 }
14374 184320 }
14375
14376 92160 }
14377
14378
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 92160 times.
196608 if(guyversion >= 37)
14379 {
14380
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.editorflags),f))
14381 {
14382 return qe_invalid;
14383 }
14384 92160 }
14385
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14386
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 92160 times.
196608 if(guyversion >= 38)
14387 {
14388
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.attributes[12]),f))
14389 {
14390 return qe_invalid;
14391 }
14392
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.attributes[13]),f))
14393 {
14394 return qe_invalid;
14395 }
14396
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetl(&(tempguy.attributes[14]),f))
14397 {
14398 return qe_invalid;
14399 }
14400
14401 92160 }
14402
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if ( guyversion < 38 )
14403 {
14404 104448 tempguy.attributes[12] = 0;
14405 104448 tempguy.attributes[13] = 0;
14406 104448 tempguy.attributes[14] = 0;
14407 104448 }
14408
14409
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 92160 times.
196608 if ( guyversion >= 39 )
14410 {
14411
2/2
✓ Branch 0 taken 737280 times.
✓ Branch 1 taken 92160 times.
829440 for ( int32_t q = 0; q < 8; q++ )
14412 {
14413
2/2
✓ Branch 0 taken 47923200 times.
✓ Branch 1 taken 737280 times.
48660480 for ( int32_t w = 0; w < 65; w++ )
14414 {
14415
1/2
✓ Branch 0 taken 47923200 times.
✗ Branch 1 not taken.
47923200 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14416 {
14417 return qe_invalid;
14418 }
14419 47923200 }
14420
2/2
✓ Branch 0 taken 47923200 times.
✓ Branch 1 taken 737280 times.
48660480 for ( int32_t w = 0; w < 65; w++ )
14421 {
14422
1/2
✓ Branch 0 taken 47923200 times.
✗ Branch 1 not taken.
47923200 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14423 {
14424 return qe_invalid;
14425 }
14426 47923200 }
14427 737280 }
14428
14429
14430 92160 }
14431
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if ( guyversion < 39 ) //apply old InitD strings to both
14432 {
14433
2/2
✓ Branch 0 taken 835584 times.
✓ Branch 1 taken 104448 times.
940032 for ( int32_t q = 0; q < 8; q++ )
14434 {
14435 835584 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14436 835584 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14437 835584 }
14438 104448 }
14439
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 92160 times.
196608 if ( guyversion >= 40 )
14440 {
14441
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_igetw(&(tempguy.weaponscript),f))
14442 {
14443 return qe_invalid;
14444 }
14445 92160 }
14446
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if ( guyversion < 40 )
14447 {
14448 104448 tempguy.weaponscript = 0;
14449 104448 }
14450 //eweapon script InitD
14451
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 92160 times.
196608 if ( guyversion >= 41 )
14452 {
14453
2/2
✓ Branch 0 taken 737280 times.
✓ Branch 1 taken 92160 times.
829440 for ( int32_t q = 0; q < 8; q++ )
14454 {
14455
1/2
✓ Branch 0 taken 737280 times.
✗ Branch 1 not taken.
737280 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14456 {
14457 return qe_invalid;
14458 }
14459 737280 }
14460
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if ( guy_cversion < 4 )
14461 {
14462 if ( tempguy.family == eeKEESE )
14463 {
14464
14465 if ( !tempguy.attributes[0] )
14466 {
14467 tempguy.attributes[15] = 120;
14468 tempguy.attributes[16] = 16;
14469
14470 }
14471 }
14472 if ( tempguy.family == eePEAHAT )
14473 {
14474 tempguy.attributes[15] = 80;
14475 tempguy.attributes[16] = 16;
14476 }
14477
14478 if ( tempguy.family == eeGHINI )
14479 {
14480 tempguy.attributes[15] = 120;
14481 tempguy.attributes[16] = 10;
14482 }
14483
14484 }
14485 92160 }
14486
14487
14488
14489 //default weapon sprites (quest version < 2.54)
14490 //port over old defaults -Z
14491
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if(guyversion < 32)
14492 {
14493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if ( tempguy.wpnsprite <= 0 )
14494 {
14495
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2887 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 88705 times.
✓ Branch 4 taken 810 times.
✓ Branch 5 taken 706 times.
✓ Branch 6 taken 1929 times.
✓ Branch 7 taken 1305 times.
✓ Branch 8 taken 2422 times.
✓ Branch 9 taken 210 times.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 454 times.
✓ Branch 12 taken 78 times.
✓ Branch 13 taken 924 times.
✓ Branch 14 taken 1840 times.
✓ Branch 15 taken 234 times.
✓ Branch 16 taken 328 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1538 times.
104448 switch(tempguy.weapon)
14496 {
14497 case wNone:
14498 88705 tempguy.wpnsprite = 0; break;
14499
14500 case wSword:
14501 case wBeam:
14502 case wBrang:
14503 case wBomb:
14504 case wSBomb:
14505 case wLitBomb:
14506 case wLitSBomb:
14507 case wArrow:
14508 case wFire:
14509 case wWhistle:
14510 case wBait:
14511 case wWand:
14512 case wMagic:
14513 case wCatching:
14514 case wWind:
14515 case wRefMagic:
14516 case wRefFireball:
14517 case wRefRock:
14518 case wHammer:
14519 case wHookshot:
14520 case wHSHandle:
14521 case wHSChain:
14522 case wSSparkle:
14523 case wFSparkle:
14524 case wSmack:
14525 case wPhantom:
14526 case wCByrna:
14527 case wRefBeam:
14528 case wStomp:
14529 case lwMax:
14530 case wScript1:
14531 case wScript2:
14532 case wScript3:
14533 case wScript4:
14534 case wScript5:
14535 case wScript6:
14536 case wScript7:
14537 case wScript8:
14538 case wScript9:
14539 case wScript10:
14540 case wIce:
14541 //Cannot use any of these weapons yet.
14542 tempguy.wpnsprite = -1;
14543 break;
14544
14545 case wEnemyWeapons:
14546 2887 case ewFireball: tempguy.wpnsprite = 17; break;
14547
14548 810 case ewArrow: tempguy.wpnsprite = 19; break;
14549 706 case ewBrang: tempguy.wpnsprite = 4; break;
14550 1929 case ewSword: tempguy.wpnsprite = 20; break;
14551 1305 case ewRock: tempguy.wpnsprite = 18; break;
14552 2422 case ewMagic: tempguy.wpnsprite = 21; break;
14553 210 case ewBomb: tempguy.wpnsprite = 78; break;
14554 78 case ewSBomb: tempguy.wpnsprite = 79; break;
14555 454 case ewLitBomb: tempguy.wpnsprite = 76; break;
14556 78 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14557 924 case ewFireTrail: tempguy.wpnsprite = 80; break;
14558 1840 case ewFlame: tempguy.wpnsprite = 35; break;
14559 234 case ewWind: tempguy.wpnsprite = 36; break;
14560 328 case ewFlame2: tempguy.wpnsprite = 81; break;
14561 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14562 case ewIce: tempguy.wpnsprite = 83; break;
14563 1538 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14564
14565
14566 default: break; //No assign.
14567 }
14568 104448 }
14569 104448 }
14570
14571 //default weapon fire sound (quest version < 2.54)
14572 //port over old defaults and zero new data. -Z
14573
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if(guyversion < 34)
14574 {
14575
2/2
✓ Branch 0 taken 3342336 times.
✓ Branch 1 taken 104448 times.
3446784 for ( int32_t q = 0; q < 32; q++ )
14576 {
14577 3342336 tempguy.movement[q] = 0;
14578 3342336 tempguy.new_weapon[q] = 0;
14579
14580 3342336 }
14581
14582 //NPC Script attributes.
14583 104448 tempguy.script = 0; //No scripted enemies existed. -Z
14584
2/2
✓ Branch 0 taken 835584 times.
✓ Branch 1 taken 104448 times.
940032 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14585
14586
2/2
✓ Branch 0 taken 1775616 times.
✓ Branch 1 taken 104448 times.
1880064 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14587
14588 //old default sounds
14589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if ( tempguy.firesfx <= 0 )
14590 {
14591
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2887 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 88705 times.
✓ Branch 4 taken 810 times.
✓ Branch 5 taken 706 times.
✓ Branch 6 taken 1929 times.
✓ Branch 7 taken 1305 times.
✓ Branch 8 taken 2422 times.
✓ Branch 9 taken 210 times.
✓ Branch 10 taken 78 times.
✓ Branch 11 taken 454 times.
✓ Branch 12 taken 78 times.
✓ Branch 13 taken 924 times.
✓ Branch 14 taken 1840 times.
✓ Branch 15 taken 234 times.
✓ Branch 16 taken 328 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1538 times.
104448 switch(tempguy.weapon)
14592 {
14593 case wNone:
14594 88705 tempguy.firesfx = 0; break;
14595
14596 case wSword:
14597 case wBeam:
14598 case wBrang:
14599 case wBomb:
14600 case wSBomb:
14601 case wLitBomb:
14602 case wLitSBomb:
14603 case wArrow:
14604 case wFire:
14605 case wWhistle:
14606 case wBait:
14607 case wWand:
14608 case wMagic:
14609 case wCatching:
14610 case wWind:
14611 case wRefMagic:
14612 case wRefFireball:
14613 case wRefRock:
14614 case wHammer:
14615 case wHookshot:
14616 case wHSHandle:
14617 case wHSChain:
14618 case wSSparkle:
14619 case wFSparkle:
14620 case wSmack:
14621 case wPhantom:
14622 case wCByrna:
14623 case wRefBeam:
14624 case wStomp:
14625 case lwMax:
14626 case wScript1:
14627 case wScript2:
14628 case wScript3:
14629 case wScript4:
14630 case wScript5:
14631 case wScript6:
14632 case wScript7:
14633 case wScript8:
14634 case wScript9:
14635 case wScript10:
14636 case wIce:
14637 //Cannot use any of these weapons yet.
14638 tempguy.firesfx = -1;
14639 break;
14640
14641 case wEnemyWeapons:
14642 2887 case ewFireball: tempguy.firesfx = 40; break;
14643
14644 810 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14645 706 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14646 1929 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14647 1305 case ewRock: tempguy.firesfx = 51; break;
14648 2422 case ewMagic: tempguy.firesfx = 32; break;
14649 210 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14650 78 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14651 454 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14652 78 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14653 924 case ewFireTrail: tempguy.firesfx = 13; break;
14654 1840 case ewFlame: tempguy.firesfx = 13; break;
14655 234 case ewWind: tempguy.firesfx = 32; break;
14656 328 case ewFlame2: tempguy.firesfx = 13; break;
14657 case ewFlame2Trail: tempguy.firesfx = 13; break;
14658 case ewIce: tempguy.firesfx = 44; break;
14659 1538 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14660
14661 //what about special attacks (e.g. summoning == 56)
14662 default: break; //No assign.
14663 }
14664 104448 }
14665 104448 }
14666
14667 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14668
4/6
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
✓ Branch 2 taken 92160 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 92160 times.
196608 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14669 {
14670
2/2
✓ Branch 0 taken 13673 times.
✓ Branch 1 taken 90775 times.
104448 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14671 104448 }
14672 //Keese and bat halt rates.
14673
3/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 92160 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104448 times.
196608 if ( guyversion < 42 && guy_cversion < 4 )
14674 {
14675
14676
2/2
✓ Branch 0 taken 103133 times.
✓ Branch 1 taken 1315 times.
104448 if ( tempguy.family == eeKEESE )
14677 {
14678
14679
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 951 times.
1315 if ( !tempguy.attributes[0] )
14680 {
14681 951 tempguy.attributes[15] = 120;
14682 951 tempguy.attributes[16] = 16;
14683
14684 951 }
14685 1315 }
14686
2/2
✓ Branch 0 taken 103975 times.
✓ Branch 1 taken 473 times.
104448 if ( tempguy.family == eePEAHAT )
14687 {
14688 473 tempguy.attributes[15] = 80;
14689 473 tempguy.attributes[16] = 16;
14690 473 }
14691
2/2
✓ Branch 0 taken 104244 times.
✓ Branch 1 taken 204 times.
104448 if ( tempguy.family == eeGHINI )
14692 {
14693 204 tempguy.attributes[15] = 120;
14694 204 tempguy.attributes[16] = 10;
14695 204 }
14696
14697
14698 104448 }
14699
14700
14701 //miscellaneous other corrections
14702 //fix the mirror wizzrobe -DD
14703
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 7)
14704 {
14705 if(i == eMWIZ)
14706 {
14707 tempguy.attributes[1] = 0;
14708 tempguy.attributes[3] = 1;
14709 }
14710 }
14711
14712
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 8)
14713 {
14714 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14715 {
14716 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14717 tempguy.attributes[4] = 4; //neck length in segments
14718 tempguy.attributes[5] = 8; //neck offset from first body tile
14719 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
14720 tempguy.attributes[7] = 168; //head offset from first body tile
14721 tempguy.attributes[8] = 228; //flying head offset from first body tile
14722
14723 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14724 {
14725 tempguy.attributes[5] += 10; //neck offset from first body tile
14726 tempguy.attributes[7] -= 12; //head offset from first body tile
14727 }
14728 }
14729 }
14730
14731
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14732 {
14733 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.attributes[0]==0)
14734 tempguy.bosspal = spDIG;
14735 }
14736
14737
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 11) // December 2007 - Spinning Tile fix
14738 {
14739 if(tempguy.family==eeSPINTILE)
14740 {
14741 tempguy.flags |= guy_superman;
14742 tempguy.item_set = 0; // Don't drop items
14743 tempguy.step = 300;
14744 }
14745 }
14746
14747
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14748 {
14749 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14750 {
14751 if(tempguy.family==eeROPE)
14752 {
14753 tempguy.flags &= ~guy_flashing;
14754 }
14755 }
14756
14757 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14758 {
14759 if(tempguy.family==eeBUBBLE)
14760 {
14761 tempguy.flags &= ~guy_flashing;
14762 }
14763 }
14764
14765 if((tempguy.family==eeGHINI)&&(tempguy.attributes[0]))
14766 {
14767 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14768 {
14769 tempguy.flags |= guy_blinking;
14770 }
14771
14772 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14773 {
14774 tempguy.flags |= guy_transparent;
14775 }
14776 }
14777 }
14778
14779
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14780 {
14781 if(i==gFIRE)
14782 {
14783 tempguy.e_anim = aFLIP;
14784 tempguy.e_frate = 24;
14785 }
14786
14787 if(i==gFAIRY)
14788 {
14789 tempguy.e_anim = a2FRM;
14790 tempguy.e_frate = 16;
14791 }
14792 }
14793
14794
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14795 {
14796 if(i==0) Z_message("Updating guys to version 16...\n");
14797
14798 update_guy_1(&tempguy);
14799
14800 if(i==eMPOLSV)
14801 {
14802 tempguy.defense[edefARROW] = edCHINK;
14803 tempguy.defense[edefMAGIC] = ed1HKO;
14804 tempguy.defense[edefREFMAGIC] = ed1HKO;
14805 }
14806 }
14807
14808
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 17) // December 2009
14809 {
14810 if(tempguy.family==eePROJECTILE)
14811 {
14812 tempguy.attributes[0] = 0;
14813 }
14814 }
14815
14816
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 18) // January 2010
14817 {
14818 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14819 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14820
14821 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14822 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
14823
14824 if(tempguy.family == eeAQUA)
14825 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14826 else if(tempguy.family == eeMANHAN)
14827 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14828 else if(tempguy.family==eePATRA)
14829 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14830 else if(tempguy.family==eeGHOMA)
14831 {
14832 for(int32_t j=0; j<edefLAST; j++)
14833 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14834
14835 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
14836
14837 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14838
14839 tempguy.attributes[0]--;
14840 }
14841 else if(tempguy.family == eeGLEEOK)
14842 {
14843 for(int32_t j=0; j<edefLAST; j++)
14844 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14845
14846 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14847 }
14848 else if(tempguy.family == eeARMOS)
14849 {
14850 tempguy.family=eeWALK;
14851 tempguy.hrate = 0;
14852 tempguy.attributes[9] = tempguy.attributes[0];
14853 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14854 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14855 tempguy.attributes[8] = e9tARMOS;
14856 }
14857 else if(tempguy.family == eeGHINI && !tempguy.attributes[0])
14858 {
14859 tempguy.family=eeWALK;
14860 tempguy.hrate = 0;
14861 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
14862 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
14863 }
14864
14865 // Spawn animation flags
14866 if(tempguy.family == eeWALK && (tempguy.flags&guy_armos || tempguy.flags&guy_ghini))
14867 tempguy.flags |= guy_fade_flicker;
14868 else
14869 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
14870 }
14871
14872
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 20) // April 2010
14873 {
14874 if(tempguy.family == eeTRAP)
14875 {
14876 tempguy.attributes[1] = tempguy.attributes[9];
14877
14878 if(tempguy.attributes[9]>=1)
14879 {
14880 tempguy.attributes[0]++;
14881 }
14882
14883 tempguy.attributes[9] = 0;
14884 }
14885
14886 // Bomb Blast fix
14887 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14888 tempguy.weapon = ewLitBomb;
14889 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14890 tempguy.weapon = ewLitSBomb;
14891 }
14892
14893
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 21) // September 2011
14894 {
14895 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14896 {
14897 if(tempguy.family == eeKEESETRIB)
14898 {
14899 tempguy.family = eeKEESE;
14900 tempguy.attributes[1] = e2tKEESETRIB;
14901 tempguy.attributes[0] = 0;
14902 }
14903
14904 tempguy.rate = 2;
14905 tempguy.hrate = 8;
14906 tempguy.homing = 0;
14907 tempguy.step= (tempguy.family == eeKEESE && tempguy.attributes[0] ? 100:62);
14908 }
14909 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14910 {
14911 if(tempguy.family == eePEAHAT)
14912 {
14913 tempguy.rate = 4;
14914 tempguy.step = 62;
14915 }
14916 else
14917 tempguy.step = 25;
14918
14919 tempguy.hrate = 8;
14920 tempguy.homing = 0;
14921 }
14922 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14923 {
14924 if(tempguy.family == eeMANHAN)
14925 tempguy.step=50;
14926
14927 tempguy.hrate = 16;
14928 tempguy.homing = 0;
14929 }
14930 else if(tempguy.family == eeGLEEOK)
14931 {
14932 tempguy.rate = 2;
14933 tempguy.homing = 0;
14934 tempguy.hrate = 9;
14935 tempguy.step=89;
14936 }
14937 else if(tempguy.family == eeGHINI)
14938 {
14939 tempguy.rate = 4;
14940 tempguy.hrate = 12;
14941 tempguy.step=62;
14942 tempguy.homing = 0;
14943 }
14944
14945 // Bigdig random rate fix
14946 if(tempguy.family==eeDIG && tempguy.attributes[9]==1)
14947 {
14948 tempguy.rate = 2;
14949 }
14950 }
14951
14952
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(guyversion < 24) // November 2012
14953 {
14954 if(tempguy.family==eeLANM)
14955 tempguy.attributes[2] = 1;
14956 else if(tempguy.family==eeMOLD)
14957 tempguy.attributes[1] = 0;
14958 }
14959
14960
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14961 {
14962
2/2
✓ Branch 0 taken 1429 times.
✓ Branch 1 taken 103019 times.
104448 if(tempguy.family!=eeDIG)
14963 {
14964 103019 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14965 103019 }
14966
14967 104448 }
14968 // does not seem to solve the issue!
14969
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if ( Header->zelda_version <= 0x210 )
14970 {
14971 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14972 if ( tempguy.family == eeDONGO )
14973 {
14974 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14975 }
14976 }
14977
14978
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if(guyversion >= 42)
14979 {
14980
2/2
✓ Branch 0 taken 89600 times.
✓ Branch 1 taken 2560 times.
92160 if(guyversion >= 47)
14981 {
14982
1/2
✓ Branch 0 taken 89600 times.
✗ Branch 1 not taken.
89600 if(!p_igetl(&(tempguy.moveflags),f))
14983 {
14984 return qe_invalid;
14985 }
14986 89600 }
14987 else
14988 {
14989 byte fl;
14990
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
14991 {
14992 return qe_invalid;
14993 }
14994 2560 tempguy.moveflags = (move_flags)fl;
14995 }
14996 92160 }
14997 else
14998 {
14999
7/8
✓ Branch 0 taken 2842 times.
✓ Branch 1 taken 82683 times.
✓ Branch 2 taken 2762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 965 times.
✓ Branch 5 taken 654 times.
✓ Branch 6 taken 505 times.
✓ Branch 7 taken 14037 times.
104448 switch(tempguy.family)
15000 {
15001 //No gravity; floats over pits
15002 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15003 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15004 //Special (bosses, etc)
15005 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15006 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15007 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15008 82683 tempguy.moveflags = move_can_pitwalk;
15009 82683 break;
15010 //No gravity, but falls in pits
15011 case eeLEV:
15012 965 tempguy.moveflags = move_can_pitfall;
15013 965 break;
15014 //Bosses that respect pits
15015 case eeDONGO:
15016 654 tempguy.moveflags = move_obeys_grav;
15017 654 break;
15018 case eeLANM:
15019 505 tempguy.moveflags = move_none;
15020 505 break;
15021 //Gravity, floats over pits
15022 case eeWIZZ: case eeWALLM: case eeGHINI:
15023 2762 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
15024 2762 break;
15025 //Gravity and falls in pits
15026 case eeWALK:
15027
4/4
✓ Branch 0 taken 13329 times.
✓ Branch 1 taken 708 times.
✓ Branch 2 taken 537 times.
✓ Branch 3 taken 12792 times.
14037 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
15028 1245 break;
15029 [[fallthrough]];
15030 case eeOTHER:
15031 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15032 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15033 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15034 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15035 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15036 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15037 15634 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
15038 15634 }
15039 }
15040
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if(guyversion < 43)
15041 {
15042
2/2
✓ Branch 0 taken 85445 times.
✓ Branch 1 taken 19003 times.
104448 switch(tempguy.family)
15043 {
15044 //No gravity; floats over pits
15045 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15046 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15047 //Special (bosses, etc)
15048 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15049 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15050 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15051 case eeWIZZ: case eeWALLM: case eeGHINI:
15052 //Gravity, floats over pits
15053 85445 tempguy.moveflags |= move_can_waterwalk;
15054 85445 tempguy.moveflags |= move_can_pitwalk;
15055 85445 break;
15056 }
15057 104448 }
15058
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if (guyversion < 44)
15059 {
15060
2/2
✓ Branch 0 taken 103517 times.
✓ Branch 1 taken 931 times.
104448 if ( tempguy.family == eeGHOMA )
15061 {
15062 931 tempguy.flags |= guy_fade_instant;
15063 931 }
15064 104448 }
15065
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if (guyversion > 44)
15066 {
15067
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_getc(&(tempguy.spr_shadow),f))
15068 {
15069 return qe_invalid;
15070 }
15071
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_getc(&(tempguy.spr_death),f))
15072 {
15073 return qe_invalid;
15074 }
15075
1/2
✓ Branch 0 taken 92160 times.
✗ Branch 1 not taken.
92160 if(!p_getc(&(tempguy.spr_spawn),f))
15076 {
15077 return qe_invalid;
15078 }
15079 92160 }
15080 else
15081 {
15082
2/2
✓ Branch 0 taken 104042 times.
✓ Branch 1 taken 406 times.
104448 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
15083 104448 tempguy.spr_death = iwDeath;
15084 104448 tempguy.spr_spawn = iwSpawn;
15085 }
15086
15087
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 104448 times.
196608 if(guyversion < 46)
15088 {
15089
4/4
✓ Branch 0 taken 14037 times.
✓ Branch 1 taken 90411 times.
✓ Branch 2 taken 13329 times.
✓ Branch 3 taken 708 times.
104448 if(tempguy.family == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
15090 {
15091 708 tempguy.moveflags |= move_can_waterwalk;
15092 708 }
15093 104448 }
15094
15095
2/2
✓ Branch 0 taken 89600 times.
✓ Branch 1 taken 107008 times.
196608 if (guyversion < 47)
15096 {
15097
4/4
✓ Branch 0 taken 1459 times.
✓ Branch 1 taken 105549 times.
✓ Branch 2 taken 876 times.
✓ Branch 3 taken 583 times.
107008 if (tempguy.family == eeDIG && tempguy.attributes[9]!=1)
15098 {
15099 583 tempguy.flags |= guy_ignore_kill_all;
15100 583 }
15101 107008 }
15102
15103
2/2
✓ Branch 0 taken 69120 times.
✓ Branch 1 taken 127488 times.
196608 if (guyversion < 49)
15104 {
15105
8/8
✓ Branch 0 taken 16566 times.
✓ Branch 1 taken 110922 times.
✓ Branch 2 taken 16086 times.
✓ Branch 3 taken 480 times.
✓ Branch 4 taken 15594 times.
✓ Branch 5 taken 492 times.
✓ Branch 6 taken 537 times.
✓ Branch 7 taken 15057 times.
127488 if (tempguy.family == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
15106 {
15107
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
✓ Branch 2 taken 727 times.
✓ Branch 3 taken 61 times.
1509 switch (tempguy.attributes[7]) {
15108 case 0: //Sword
15109 721 tempguy.attributes[7] = e8tSWORD;
15110 721 break;
15111 case 1: //Item
15112 727 tempguy.attributes[7] = e8tITEM;
15113 727 break;
15114 case 2: //Both
15115 61 tempguy.attributes[7] = e8tSWORD|e8tITEM;
15116 61 break;
15117 default: //this can actually happen since Misc8 can be set to any number.
15118 tempguy.attributes[7] = 0;
15119 break;
15120 }
15121 1509 }
15122 127488 }
15123
15124 //these could possible be combined but rather be safe...
15125
2/2
✓ Branch 0 taken 69120 times.
✓ Branch 1 taken 127488 times.
196608 if (guyversion < 51) //reimport the firesfx, zoria ducked up.
15126 {
15127 127488 guy_update_firesfx(tempguy);
15128 127488 }
15129
2/2
✓ Branch 0 taken 127488 times.
✓ Branch 1 taken 69120 times.
196608 if (guyversion < 52)
15130 {
15131 127488 guy_update_weaponflags(tempguy);
15132 127488 }
15133 else
15134 {
15135
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_getc(&(tempguy.wunblockable), f))
15136 return qe_invalid;
15137
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_igetl(&(tempguy.wmoveflags), f))
15138 return qe_invalid;
15139
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_igetl(&(tempguy.weapoverrideFLAGS), f))
15140 return qe_invalid;
15141
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_igetl(&(tempguy.weap_tilew), f))
15142 return qe_invalid;
15143
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_igetl(&(tempguy.weap_tileh), f))
15144 return qe_invalid;
15145
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_igetl(&(tempguy.weap_hxsz), f))
15146 return qe_invalid;
15147
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_igetl(&(tempguy.weap_hysz), f))
15148 return qe_invalid;
15149
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_igetl(&(tempguy.weap_hzsz), f))
15150 return qe_invalid;
15151
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_igetl(&(tempguy.weap_hxofs), f))
15152 return qe_invalid;
15153
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_igetl(&(tempguy.weap_hyofs), f))
15154 return qe_invalid;
15155
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_igetl(&(tempguy.weap_xofs), f))
15156 return qe_invalid;
15157
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_igetl(&(tempguy.weap_yofs), f))
15158 return qe_invalid;
15159
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_igetl(&(tempguy.wstep), f))
15160 return qe_invalid;
15161
2/2
✓ Branch 0 taken 345600 times.
✓ Branch 1 taken 69120 times.
414720 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
15162 {
15163
1/2
✓ Branch 0 taken 345600 times.
✗ Branch 1 not taken.
345600 if (!p_igetw(&(tempguy.burnsprs[q]), f))
15164 return qe_invalid;
15165
1/2
✓ Branch 0 taken 345600 times.
✗ Branch 1 not taken.
345600 if (!p_igetw(&(tempguy.light_rads[q]), f))
15166 return qe_invalid;
15167 345600 }
15168 }
15169
2/2
✓ Branch 0 taken 127488 times.
✓ Branch 1 taken 69120 times.
196608 if (guyversion < 53)
15170 {
15171 127488 guy_update_weaponspecialsfx(tempguy);
15172 127488 }
15173 else
15174 {
15175
1/2
✓ Branch 0 taken 69120 times.
✗ Branch 1 not taken.
69120 if (!p_getc(&(tempguy.specialsfx), f))
15176 return qe_invalid;
15177 }
15178
15179
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15180 {
15181 tempguy.script = 0;
15182 for(int q = 0; q < 8; ++q)
15183 tempguy.initD[q] = 0;
15184 }
15185 196608 guysbuf[i] = tempguy;
15186 196608 }
15187 384 }
15188
15189 384 return 0;
15190 466 }
15191
15192 void update_guy_1(guydata *tempguy) // November 2009
15193 {
15194 bool doesntcount = false;
15195 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15196
15197 switch(tempguy->family)
15198 {
15199 case 1: //eeWALK
15200 switch(tempguy->attributes[9])
15201 {
15202 case 0: //Stalfos
15203 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15204 tempguy->attributes[0]=4;
15205
15206 break;
15207
15208 case 1: //Darknut
15209 goto darknuts;
15210 break;
15211 }
15212
15213 tempguy->attributes[9] = 0;
15214 break;
15215
15216 case 2: //eeSHOOT
15217 tempguy->family = eeWALK;
15218
15219 switch(tempguy->attributes[9])
15220 {
15221 case 0: //Octorok
15222 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
15223 {
15224 tempguy->attributes[0]=e1tFIREOCTO;
15225 tempguy->attributes[1]=e2tFIREOCTO;
15226 }
15227 else tempguy->attributes[0] = 0;
15228
15229 tempguy->attributes[5]=tempguy->attributes[3];
15230 tempguy->attributes[3]=tempguy->attributes[2];
15231 tempguy->attributes[2]=0;
15232 break;
15233
15234 case 1: // Moblin
15235 tempguy->attributes[0] = 0;
15236 break;
15237
15238 case 2: //Lynel
15239 tempguy->attributes[5]=tempguy->attributes[0]+1;
15240 tempguy->attributes[0]=0;
15241 break;
15242
15243 case 3: //Stalfos 2
15244 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15245 tempguy->attributes[0]=e1t4SHOTS;
15246 else tempguy->attributes[0] = 0;
15247
15248 break;
15249
15250 case 4: //Darknut 5
15251 darknuts:
15252 tempguy->defense[edefFIRE] = edIGNORE;
15253 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15254 tempguy->defense[edefHOOKSHOT] = 0;
15255 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15256 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15257
15258 if(tempguy->attributes[0]==1)
15259 tempguy->attributes[0]=2;
15260 else if(tempguy->attributes[0]==2)
15261 {
15262 tempguy->attributes[3]=tempguy->attributes[2];
15263 tempguy->attributes[2]=tempguy->attributes[1];
15264 tempguy->attributes[1]=e2tSPLIT;
15265 tempguy->attributes[0] = 0;
15266 }
15267 else tempguy->attributes[0] = 0;
15268
15269 tempguy->flags |= guy_shield_front;
15270
15271 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15272 tempguy->flags &= ~guy_bkshield;
15273 else
15274 tempguy->flags |= guy_bkshield;
15275
15276 break;
15277 }
15278
15279 tempguy->attributes[9] = 0;
15280 break;
15281
15282 /*
15283 case 9: //eeARMOS
15284 tempguy->family = eeWALK;
15285 break;
15286 */
15287 case 11: //eeGEL
15288 case 33: //eeGELTRIB
15289 if(tempguy->family==33)
15290 {
15291 tempguy->attributes[3] = 1;
15292
15293 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15294 tempguy->attributes[2] = tempguy->attributes[1];
15295
15296 tempguy->attributes[1] = e2tTRIBBLE;
15297 }
15298 else
15299 {
15300 tempguy->attributes[3] = 0;
15301 tempguy->attributes[2] = 0;
15302 tempguy->attributes[1] = 0;
15303 }
15304
15305 tempguy->family = eeWALK;
15306
15307 if(tempguy->attributes[0])
15308 {
15309 tempguy->attributes[0]=1;
15310 tempguy->weapon = ewFireTrail;
15311 }
15312
15313 break;
15314
15315 case 34: //eeZOLTRIB
15316 case 12: //eeZOL
15317 tempguy->attributes[3]=tempguy->attributes[2];
15318 tempguy->attributes[2]=tempguy->attributes[1];
15319 tempguy->family = eeWALK;
15320 tempguy->attributes[1]=e2tSPLITHIT;
15321
15322 if(tempguy->attributes[0])
15323 {
15324 tempguy->attributes[0]=1;
15325 tempguy->weapon = ewFireTrail;
15326 }
15327
15328 break;
15329
15330 case 13: //eeROPE
15331 tempguy->family = eeWALK;
15332 tempguy->attributes[8] = e9tROPE;
15333
15334 if(tempguy->attributes[0])
15335 {
15336 tempguy->attributes[3] = tempguy->attributes[2];
15337 tempguy->attributes[2] = tempguy->attributes[1];
15338 tempguy->attributes[1] = e2tBOMBCHU;
15339 }
15340
15341 tempguy->attributes[0] = 0;
15342 break;
15343
15344 case 14: //eeGORIYA
15345 tempguy->family = eeWALK;
15346
15347 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15348
15349 break;
15350
15351 case 17: //eeBUBBLE
15352 tempguy->family = eeWALK;
15353 tempguy->attributes[7] = tempguy->attributes[1];
15354 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15355 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15356
15357 //fallthrogh
15358 case eeTRAP:
15359 case eeROCK:
15360 doesntcount = true;
15361 break;
15362
15363 case 35: //eeVIRETRIB
15364 case 18: //eeVIRE
15365 tempguy->family = eeWALK;
15366 tempguy->attributes[3]=tempguy->attributes[2];
15367 tempguy->attributes[2]=tempguy->attributes[1];
15368 tempguy->attributes[1]=e2tSPLITHIT;
15369 tempguy->attributes[8]=e9tVIRE;
15370 break;
15371
15372 case 19: //eeLIKE
15373 tempguy->family = eeWALK;
15374 tempguy->attributes[6] = e7tEATITEMS;
15375 tempguy->attributes[7]=95;
15376 break;
15377
15378 case 20: //eePOLSV
15379 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15380 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15381 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15382 tempguy->defense[edefARROW] = ed1HKO;
15383 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15384 tempguy->family = eeWALK;
15385 tempguy->attributes[8] = e9tPOLSVOICE;
15386 tempguy->rate = 4;
15387 tempguy->homing = 32;
15388 tempguy->hrate = 10;
15389 tempguy->grumble = 0;
15390 break;
15391
15392 case eeWIZZ:
15393 if(tempguy->attributes[3])
15394 {
15395 for(int32_t i=0; i < edefLAST; i++)
15396 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15397 }
15398 else
15399 {
15400 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15401 tempguy->defense[edefMAGIC] = edCHINK;
15402 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15403 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15404 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15405 }
15406
15407 break;
15408
15409 case eePEAHAT:
15410 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15411
15412 if(!(tempguy->flags & guy_bhit))
15413 tempguy->defense[edefBRANG] = edSTUNONLY;
15414
15415 break;
15416
15417 case eeLEV:
15418 tempguy->defense[edefSTOMP] = edCHINK;
15419 break;
15420 }
15421
15422 // Old flags
15423 if(tempguy->flags & guy_superman)
15424 {
15425 for(int32_t i = 0; i < edefLAST; i++)
15426 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15427 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15428 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15429 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15430 }
15431
15432 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15433
15434 if(doesntcount)
15435 tempguy->flags |= (guy_doesnt_count);
15436 }
15437
15438 1167840 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
15439 {
15440 byte tempbyte, padding;
15441 int32_t extras, secretcombos;
15442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_getc(&(temp_mapscr->valid),f))
15443 {
15444 return qe_invalid;
15445 }
15446
15447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_getc(&(temp_mapscr->guy),f))
15448 return qe_invalid;
15449 1167840 temp_mapscr->guytile = -1; //signal to use default guy values
15450
2/2
✓ Branch 0 taken 1167241 times.
✓ Branch 1 taken 599 times.
1167840 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15451
4/4
✓ Branch 0 taken 599 times.
✓ Branch 1 taken 1167241 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 539 times.
1167840 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15452
15453
5/6
✓ Branch 0 taken 1145664 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1142944 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1167840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15454 {
15455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15456 {
15457 return qe_invalid;
15458 }
15459
15460 22176 temp_mapscr->str=tempbyte;
15461 22176 }
15462 else
15463 {
15464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1145664 times.
1145664 if(!p_igetw(&(temp_mapscr->str),f))
15465 {
15466 return qe_invalid;
15467 }
15468 }
15469
15470
1/2
✓ Branch 0 taken 1167840 times.
✗ Branch 1 not taken.
1167840 if(!p_getc(&(temp_mapscr->room),f))
15471 {
15472 return qe_invalid;
15473 }
15474
15475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_getc(&(temp_mapscr->item),f))
15476 {
15477 return qe_invalid;
15478 }
15479
15480
3/6
✓ Branch 0 taken 639336 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 639336 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1167840 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15481 {
15482 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15483 528504 }
15484 else
15485 {
15486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 639336 times.
639336 if(!p_getc(&(temp_mapscr->hasitem),f))
15487 return qe_invalid;
15488 }
15489
15490
3/4
✓ Branch 0 taken 1145664 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1170560 if((Header->zelda_version < 0x192)||
15491
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1142944 times.
1145664 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15492 {
15493
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15494 {
15495 return qe_invalid;
15496 }
15497 22176 }
15498
15499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15500 {
15501 return qe_invalid;
15502 }
15503
15504
2/2
✓ Branch 0 taken 1142944 times.
✓ Branch 1 taken 24896 times.
1167840 if(Header->zelda_version < 0x193)
15505 {
15506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15507 {
15508 return qe_invalid;
15509 }
15510 24896 }
15511
15512
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15513 {
15514
2/2
✓ Branch 0 taken 1918008 times.
✓ Branch 1 taken 639336 times.
2557344 for(int32_t i=1; i<4; i++)
15515 {
15516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1918008 times.
1918008 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15517 {
15518 return qe_invalid;
15519 }
15520 1918008 }
15521 639336 }
15522 else
15523 {
15524 528504 temp_mapscr->tilewarptype[1]=0;
15525 528504 temp_mapscr->tilewarptype[2]=0;
15526 528504 temp_mapscr->tilewarptype[3]=0;
15527 }
15528
15529
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1142944 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15530 {
15531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1145664 times.
1145664 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15532 {
15533 return qe_invalid;
15534 }
15535 1145664 }
15536
15537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15538 {
15539 return qe_invalid;
15540 }
15541
15542 1167840 temp_mapscr->warpreturnx[1]=0;
15543 1167840 temp_mapscr->warpreturnx[2]=0;
15544 1167840 temp_mapscr->warpreturnx[3]=0;
15545
15546
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15547 {
15548
2/2
✓ Branch 0 taken 1918008 times.
✓ Branch 1 taken 639336 times.
2557344 for(int32_t i=1; i<4; i++)
15549 {
15550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1918008 times.
1918008 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15551 {
15552 return qe_invalid;
15553 }
15554 1918008 }
15555 639336 }
15556
15557
1/2
✓ Branch 0 taken 1167840 times.
✗ Branch 1 not taken.
1167840 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15558 {
15559 return qe_invalid;
15560 }
15561
15562 1167840 temp_mapscr->warpreturny[1]=0;
15563 1167840 temp_mapscr->warpreturny[2]=0;
15564 1167840 temp_mapscr->warpreturny[3]=0;
15565
15566
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15567 {
15568
2/2
✓ Branch 0 taken 1918008 times.
✓ Branch 1 taken 639336 times.
2557344 for(int32_t i=1; i<4; i++)
15569 {
15570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1918008 times.
1918008 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15571 {
15572 return qe_invalid;
15573 }
15574 1918008 }
15575
15576
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(version>=18)
15577 {
15578
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15579 {
15580 return qe_invalid;
15581 }
15582 639336 }
15583 else
15584 {
15585 byte temp;
15586
15587 if(!p_getc(&temp,f))
15588 {
15589 return qe_invalid;
15590 }
15591
15592 temp_mapscr->warpreturnc=temp<<8|temp;
15593 }
15594 639336 }
15595
15596
1/2
✓ Branch 0 taken 1167840 times.
✗ Branch 1 not taken.
1167840 if(!p_getc(&(temp_mapscr->stairx),f))
15597
15598 {
15599 return qe_invalid;
15600 }
15601
15602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_getc(&(temp_mapscr->stairy),f))
15603 {
15604 return qe_invalid;
15605 }
15606
15607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_getc(&(temp_mapscr->itemx),f))
15608 {
15609 return qe_invalid;
15610 }
15611
15612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_getc(&(temp_mapscr->itemy),f))
15613 {
15614 return qe_invalid;
15615 }
15616
15617
2/2
✓ Branch 0 taken 639336 times.
✓ Branch 1 taken 528504 times.
1167840 if(version > 15) // February 2009
15618 {
15619
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_igetw(&(temp_mapscr->color),f))
15620 {
15621 return qe_invalid;
15622 }
15623 639336 }
15624 else
15625 {
15626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15627 {
15628 return qe_invalid;
15629 }
15630
15631 528504 temp_mapscr->color = (word) tempbyte;
15632 }
15633
15634
1/2
✓ Branch 0 taken 1167840 times.
✗ Branch 1 not taken.
1167840 if(!p_getc(&(temp_mapscr->flags11),f))
15635 {
15636 return qe_invalid;
15637 }
15638
15639
2/2
✓ Branch 0 taken 4671360 times.
✓ Branch 1 taken 1167840 times.
5839200 for(int32_t k=0; k<4; k++)
15640 {
15641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4671360 times.
4671360 if(!p_getc(&(temp_mapscr->door[k]),f))
15642 {
15643 return qe_invalid;
15644
15645 }
15646 4671360 }
15647
15648
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
1167840 if(version <= 11)
15649 {
15650
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15651 {
15652 return qe_invalid;
15653 }
15654
15655 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15656
15657
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15658 {
15659 for(int32_t i=1; i<4; i++)
15660 {
15661 if(!p_getc(&(tempbyte),f))
15662 {
15663 return qe_invalid;
15664 }
15665
15666 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15667 }
15668 }
15669 else
15670 {
15671 528504 temp_mapscr->tilewarpdmap[1]=0;
15672 528504 temp_mapscr->tilewarpdmap[2]=0;
15673 528504 temp_mapscr->tilewarpdmap[3]=0;
15674 }
15675 528504 }
15676 else
15677 {
15678
2/2
✓ Branch 0 taken 2557344 times.
✓ Branch 1 taken 639336 times.
3196680 for(int32_t i=0; i<4; i++)
15679 {
15680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2557344 times.
2557344 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15681 {
15682 return qe_invalid;
15683 }
15684 2557344 }
15685 }
15686
15687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15688 {
15689 return qe_invalid;
15690 }
15691
15692
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15693 {
15694
2/2
✓ Branch 0 taken 1918008 times.
✓ Branch 1 taken 639336 times.
2557344 for(int32_t i=1; i<4; i++)
15695 {
15696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1918008 times.
1918008 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15697 {
15698 return qe_invalid;
15699 }
15700 1918008 }
15701 639336 }
15702 else
15703 {
15704 528504 temp_mapscr->tilewarpscr[1]=0;
15705 528504 temp_mapscr->tilewarpscr[2]=0;
15706 528504 temp_mapscr->tilewarpscr[3]=0;
15707 }
15708
15709
2/2
✓ Branch 0 taken 639336 times.
✓ Branch 1 taken 528504 times.
1167840 if(version >= 15)
15710 {
15711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 639336 times.
639336 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15712 {
15713 return qe_invalid;
15714 }
15715 639336 }
15716 else
15717 {
15718 528504 temp_mapscr->tilewarpoverlayflags=0;
15719 }
15720
15721
1/2
✓ Branch 0 taken 1167840 times.
✗ Branch 1 not taken.
1167840 if(!p_getc(&(temp_mapscr->exitdir),f))
15722 {
15723 return qe_invalid;
15724 }
15725
15726
2/2
✓ Branch 0 taken 1142944 times.
✓ Branch 1 taken 24896 times.
1167840 if(Header->zelda_version < 0x193)
15727 {
15728
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15729 {
15730 return qe_invalid;
15731 }
15732
15733 24896 }
15734
15735
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1165120 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15736 {
15737 if(!p_getc(&padding,f))
15738 {
15739 return qe_invalid;
15740 }
15741 }
15742
15743
2/2
✓ Branch 0 taken 11678400 times.
✓ Branch 1 taken 1167840 times.
12846240 for(int32_t k=0; k<10; k++)
15744 {
15745
5/6
✓ Branch 0 taken 11456640 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11429440 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11678400 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15746 {
15747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15748 {
15749 return qe_invalid;
15750 }
15751
15752 221760 temp_mapscr->enemy[k]=tempbyte;
15753 221760 }
15754 else
15755 {
15756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11456640 times.
11456640 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15757 {
15758 return qe_invalid;
15759 }
15760 }
15761
15762
5/6
✓ Branch 0 taken 11456640 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11429440 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11678400 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15763 {
15764 //using enumerations here is dangerous
15765 //very easy to break old quests -DD
15766
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15767 {
15768 1342 temp_mapscr->enemy[k]+=5;
15769 1342 }
15770
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15771 {
15772 94 temp_mapscr->enemy[k]+=1;
15773 94 }
15774 221760 }
15775
15776
2/2
✓ Branch 0 taken 6393360 times.
✓ Branch 1 taken 5285040 times.
11678400 if(version < 9)
15777 {
15778
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
15779 {
15780 275905 temp_mapscr->enemy[k]+=10;
15781 275905 }
15782 5285040 }
15783 //don't read in any invalid data
15784
2/2
✓ Branch 0 taken 11677950 times.
✓ Branch 1 taken 450 times.
11678400 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15785 {
15786 450 al_trace("Tried to read an invalid enemy ID (%d) for enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15787 450 temp_mapscr->enemy[k] = 0;
15788 450 }
15789 11678400 }
15790
15791
1/2
✓ Branch 0 taken 1167840 times.
✗ Branch 1 not taken.
1167840 if(!p_getc(&(temp_mapscr->pattern),f))
15792 {
15793 return qe_invalid;
15794 }
15795
15796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15797 {
15798 return qe_invalid;
15799 }
15800
15801
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15802 {
15803
2/2
✓ Branch 0 taken 1918008 times.
✓ Branch 1 taken 639336 times.
2557344 for(int32_t i=1; i<4; i++)
15804 {
15805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1918008 times.
1918008 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15806 {
15807 return qe_invalid;
15808 }
15809 1918008 }
15810 639336 }
15811 else
15812 {
15813 528504 temp_mapscr->sidewarptype[1]=0;
15814 528504 temp_mapscr->sidewarptype[2]=0;
15815 528504 temp_mapscr->sidewarptype[3]=0;
15816 }
15817
15818
2/2
✓ Branch 0 taken 639336 times.
✓ Branch 1 taken 528504 times.
1167840 if(version >= 15)
15819 {
15820
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15821 {
15822 return qe_invalid;
15823 }
15824 639336 }
15825 else
15826 {
15827 528504 temp_mapscr->sidewarpoverlayflags=0;
15828 }
15829
15830
1/2
✓ Branch 0 taken 1167840 times.
✗ Branch 1 not taken.
1167840 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15831 {
15832 return qe_invalid;
15833 }
15834
15835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15836 {
15837 return qe_invalid;
15838 }
15839
15840
2/2
✓ Branch 0 taken 4671360 times.
✓ Branch 1 taken 1167840 times.
5839200 for(int32_t k=0; k<4; k++)
15841 {
15842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4671360 times.
4671360 if(!p_getc(&(temp_mapscr->path[k]),f))
15843 {
15844 return qe_invalid;
15845 }
15846 4671360 }
15847
15848
1/2
✓ Branch 0 taken 1167840 times.
✗ Branch 1 not taken.
1167840 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15849 {
15850 return qe_invalid;
15851 }
15852
15853
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15854 {
15855
2/2
✓ Branch 0 taken 639336 times.
✓ Branch 1 taken 1918008 times.
2557344 for(int32_t i=1; i<4; i++)
15856 {
15857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1918008 times.
1918008 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15858 {
15859 return qe_invalid;
15860 }
15861 1918008 }
15862 639336 }
15863 else
15864 {
15865 528504 temp_mapscr->sidewarpscr[1]=0;
15866 528504 temp_mapscr->sidewarpscr[2]=0;
15867 528504 temp_mapscr->sidewarpscr[3]=0;
15868 }
15869
15870
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
1167840 if(version <= 11)
15871 {
15872
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15873 {
15874 return qe_invalid;
15875 }
15876
15877 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15878
15879
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15880 {
15881 for(int32_t i=1; i<4; i++)
15882 {
15883 if(!p_getc(&(tempbyte),f))
15884 {
15885 return qe_invalid;
15886 }
15887
15888 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15889 }
15890 }
15891 else
15892 {
15893 528504 temp_mapscr->sidewarpdmap[1]=0;
15894 528504 temp_mapscr->sidewarpdmap[2]=0;
15895 528504 temp_mapscr->sidewarpdmap[3]=0;
15896 }
15897 528504 }
15898 else
15899 {
15900
2/2
✓ Branch 0 taken 2557344 times.
✓ Branch 1 taken 639336 times.
3196680 for(int32_t i=0; i<4; i++)
15901 {
15902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2557344 times.
2557344 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15903 {
15904 return qe_invalid;
15905 }
15906 2557344 }
15907 }
15908
15909
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15910 {
15911
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15912 {
15913 return qe_invalid;
15914 }
15915 639336 }
15916 528504 else temp_mapscr->sidewarpindex = 0;
15917
15918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_igetw(&(temp_mapscr->undercombo),f))
15919 {
15920 return qe_invalid;
15921 }
15922
15923
2/2
✓ Branch 0 taken 1142944 times.
✓ Branch 1 taken 24896 times.
1167840 if(Header->zelda_version < 0x193)
15924 {
15925
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if (!p_getc(&old_combo_pages[scrind], f))
15926 {
15927 return qe_invalid;
15928 }
15929 24896 }
15930
15931
1/2
✓ Branch 0 taken 1167840 times.
✗ Branch 1 not taken.
1167840 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15932 {
15933 return qe_invalid;
15934 }
15935
15936
1/2
✓ Branch 0 taken 1167840 times.
✗ Branch 1 not taken.
1167840 if(!p_igetw(&(temp_mapscr->catchall),f))
15937 {
15938 return qe_invalid;
15939 }
15940
15941
1/2
✓ Branch 0 taken 1167840 times.
✗ Branch 1 not taken.
1167840 if(!p_getc(&(temp_mapscr->flags),f))
15942 {
15943 return qe_invalid;
15944 }
15945
15946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_getc(&(temp_mapscr->flags2),f))
15947 {
15948 return qe_invalid;
15949 }
15950
15951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(!p_getc(&(temp_mapscr->flags3),f))
15952 {
15953 return qe_invalid;
15954 }
15955
15956
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15957 //if (version>2)
15958 {
15959
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_getc(&(temp_mapscr->flags4),f))
15960 {
15961 return qe_invalid;
15962 }
15963 639336 }
15964
15965
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15966 {
15967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 639336 times.
639336 if(!p_getc(&(temp_mapscr->flags5),f))
15968 {
15969 return qe_invalid;
15970 }
15971
15972
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_igetw(&(temp_mapscr->noreset),f))
15973 {
15974 return qe_invalid;
15975 }
15976
15977
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_igetw(&(temp_mapscr->nocarry),f))
15978 {
15979 return qe_invalid;
15980 }
15981
15982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 639336 times.
639336 if(temp_mapscr->flags5&32)
15983 {
15984 temp_mapscr->flags5 &= ~32;
15985 temp_mapscr->noreset |= 48;
15986 }
15987
15988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 639336 times.
639336 if(version<8)
15989 {
15990 if(temp_mapscr->noreset&1)
15991 {
15992 temp_mapscr->noreset|=8192;
15993 }
15994
15995 if(temp_mapscr->nocarry&1)
15996 {
15997 temp_mapscr->nocarry|=8192;
15998 temp_mapscr->nocarry&=~1;
15999 }
16000 }
16001 639336 }
16002 else
16003 {
16004 528504 temp_mapscr->flags5 = 0;
16005 528504 temp_mapscr->noreset = 0;
16006 528504 temp_mapscr->nocarry = 0;
16007 }
16008
16009
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16010 {
16011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 639336 times.
639336 if(!p_getc(&(temp_mapscr->flags6),f))
16012 {
16013 return qe_invalid;
16014 }
16015 639336 }
16016
16017
2/2
✓ Branch 0 taken 639336 times.
✓ Branch 1 taken 528504 times.
1167840 if(version>5)
16018 {
16019
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_getc(&(temp_mapscr->flags7),f))
16020 {
16021 return qe_invalid;
16022 }
16023
16024
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_getc(&(temp_mapscr->flags8),f))
16025 {
16026 return qe_invalid;
16027 }
16028
16029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 639336 times.
639336 if(!p_getc(&(temp_mapscr->flags9),f))
16030 {
16031 return qe_invalid;
16032 }
16033
16034
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_getc(&(temp_mapscr->flags10),f))
16035 {
16036 return qe_invalid;
16037 }
16038
16039
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_getc(&(temp_mapscr->csensitive),f))
16040 {
16041 return qe_invalid;
16042 }
16043 639336 }
16044 else
16045 {
16046 528504 temp_mapscr->csensitive=1;
16047 }
16048
16049
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
1167840 if(version<14) // August 2007: screen SFX added
16050 {
16051
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
16052 {
16053 994 temp_mapscr->bosssfx=
16054
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16055 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16056 WAV_ROAR;
16057 994 }
16058
16059
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA_SFX
16060 {
16061 170 temp_mapscr->oceansfx=WAV_SEA;
16062 170 }
16063
16064 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16065 ? 0 : WAV_SECRET;
16066
16067 528504 temp_mapscr->flags3 &= ~66; //64|2
16068 528504 temp_mapscr->flags2 &= ~32;
16069 528504 temp_mapscr->flags &= ~136; // 128|8
16070 528504 }
16071 else
16072 {
16073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 639336 times.
639336 if(!p_getc(&(temp_mapscr->oceansfx),f))
16074 {
16075 return qe_invalid;
16076 }
16077
16078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 639336 times.
639336 if(!p_getc(&(temp_mapscr->bosssfx),f))
16079 {
16080 return qe_invalid;
16081 }
16082
16083
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_getc(&(temp_mapscr->secretsfx),f))
16084 {
16085 return qe_invalid;
16086 }
16087 }
16088
16089
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
1167840 if(version<15) // October 2007: another SFX
16090 {
16091 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
16092 528504 }
16093 else
16094 {
16095
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16096 {
16097 return qe_invalid;
16098 }
16099 }
16100
16101
16102
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1142944 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16103 {
16104
2/2
✓ Branch 0 taken 6873984 times.
✓ Branch 1 taken 1145664 times.
8019648 for(int32_t k=0; k<6; k++)
16105 {
16106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6873984 times.
6873984 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16107 {
16108 return qe_invalid;
16109 }
16110 6873984 }
16111
16112
2/2
✓ Branch 0 taken 1145664 times.
✓ Branch 1 taken 6873984 times.
8019648 for(int32_t k=0; k<6; k++)
16113 {
16114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6873984 times.
6873984 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16115 {
16116 return qe_invalid;
16117 }
16118 6873984 }
16119 1145664 }
16120
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16121 {
16122 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16123 {
16124 return qe_invalid;
16125 }
16126
16127 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16128 {
16129 return qe_invalid;
16130 }
16131
16132 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16133 {
16134 return qe_invalid;
16135 }
16136
16137 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16138
16139 {
16140 return qe_invalid;
16141 }
16142 }
16143
16144
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1165120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1167840 if((Header->zelda_version == 0x192)&&(Header->build>149))
16145 {
16146
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16147 {
16148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
16149 {
16150 return qe_invalid;
16151 }
16152 16320 }
16153
16154
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16155 {
16156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16157 {
16158 return qe_invalid;
16159 }
16160 16320 }
16161
16162
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16163 {
16164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16165 {
16166 return qe_invalid;
16167 }
16168 16320 }
16169
16170
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16171 {
16172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16173 {
16174 return qe_invalid;
16175 }
16176 16320 }
16177
16178
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16179 {
16180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16181 {
16182 return qe_invalid;
16183 }
16184 16320 }
16185
16186
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16187 {
16188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16189 {
16190 return qe_invalid;
16191 }
16192 16320 }
16193 2720 }
16194
16195
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1142944 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16196 {
16197
2/2
✓ Branch 0 taken 6873984 times.
✓ Branch 1 taken 1145664 times.
8019648 for(int32_t k=0; k<6; k++)
16198 {
16199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6873984 times.
6873984 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16200 {
16201 return qe_invalid;
16202 }
16203 6873984 }
16204 1145664 }
16205
16206
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1142944 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16207 {
16208
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1142944 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1145664 if((Header->zelda_version == 0x192)&&(Header->build>153))
16209 {
16210
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16211 {
16212 return qe_invalid;
16213 }
16214 2720 }
16215
16216
1/2
✓ Branch 0 taken 1145664 times.
✗ Branch 1 not taken.
1145664 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16217 {
16218 return qe_invalid;
16219 }
16220 1145664 }
16221
16222
5/6
✓ Branch 0 taken 1145664 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1142944 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1167840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16223 {
16224 22176 extras=15;
16225 22176 }
16226
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1142944 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1145664 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16227 {
16228 extras=11;
16229 }
16230
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1142944 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1145664 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16231 {
16232 extras=32;
16233 }
16234
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1142944 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1145664 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16235 {
16236 extras=64;
16237 }
16238
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1142944 times.
1145664 else if(Header->zelda_version < 0x193)
16239 {
16240 2720 extras=62;
16241 2720 }
16242 else
16243
16244 {
16245 1142944 extras=0;
16246 }
16247
16248
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1167840 times.
1669120 for(int32_t k=0; k<extras; k++)
16249 {
16250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16251 {
16252 return qe_invalid;
16253 }
16254 501280 }
16255
16256
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16257 //if (version>3)
16258 {
16259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 639336 times.
639336 if(!p_getc(&(temp_mapscr->nextmap),f))
16260 {
16261 return qe_invalid;
16262 }
16263
16264
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_getc(&(temp_mapscr->nextscr),f))
16265 {
16266 return qe_invalid;
16267 }
16268 639336 }
16269 else
16270 {
16271 528504 temp_mapscr->nextmap=0;
16272 528504 temp_mapscr->nextscr=0;
16273 }
16274
16275
5/6
✓ Branch 0 taken 1145664 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1142944 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1167840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16276 {
16277 22176 secretcombos=20;
16278 22176 }
16279
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1142944 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1145664 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16280 {
16281 secretcombos=256;
16282 }
16283 else
16284 {
16285 1145664 secretcombos=128;
16286 }
16287
16288
5/6
✓ Branch 0 taken 1145664 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1142944 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1167840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16289 {
16290
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16291 {
16292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16293 {
16294 return qe_invalid;
16295 }
16296
16297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16298 {
16299 443520 temp_mapscr->secretcombo[k]=tempbyte;
16300 443520 }
16301 443520 }
16302 22176 }
16303 else
16304 {
16305
2/2
✓ Branch 0 taken 146644992 times.
✓ Branch 1 taken 1145664 times.
147790656 for(int32_t k=0; k<128; k++)
16306 {
16307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146644992 times.
146644992 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16308 {
16309 return qe_invalid;
16310 }
16311
16312 146644992 }
16313 }
16314
16315
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1142944 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16316 {
16317
2/2
✓ Branch 0 taken 146644992 times.
✓ Branch 1 taken 1145664 times.
147790656 for(int32_t k=0; k<128; k++)
16318 {
16319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146644992 times.
146644992 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16320 {
16321 return qe_invalid;
16322 }
16323 146644992 }
16324
16325
2/2
✓ Branch 0 taken 146644992 times.
✓ Branch 1 taken 1145664 times.
147790656 for(int32_t k=0; k<128; k++)
16326 {
16327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146644992 times.
146644992 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16328 {
16329 return qe_invalid;
16330 }
16331 146644992 }
16332 1145664 }
16333
16334
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1165120 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16335 {
16336 if(!p_getc(&padding,f))
16337 {
16338 return qe_invalid;
16339 }
16340 }
16341
16342
2/2
✓ Branch 0 taken 205539840 times.
✓ Branch 1 taken 1167840 times.
206707680 for(int32_t k=0; k<176; k++)
16343 {
16344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205539840 times.
205539840 if(!p_igetw(&(temp_mapscr->data[k]),f))
16345 {
16346 return qe_invalid;
16347 }
16348 205539840 }
16349
16350
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1165120 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16351 {
16352 if(!p_getc(&padding,f))
16353 {
16354 return qe_invalid;
16355 }
16356
16357 if(!p_getc(&padding,f))
16358 {
16359 return qe_invalid;
16360 }
16361 }
16362
16363
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1142944 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16364 {
16365
2/2
✓ Branch 0 taken 201636864 times.
✓ Branch 1 taken 1145664 times.
202782528 for(int32_t k=0; k<176; k++)
16366 {
16367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201636864 times.
201636864 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16368 {
16369 return qe_invalid;
16370 }
16371
16372
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 201158144 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
201636864 if((Header->zelda_version == 0x192)&&(Header->build<24))
16373 {
16374 if(!p_getc(&tempbyte,f))
16375 {
16376 return qe_invalid;
16377 }
16378
16379 if(!p_getc(&tempbyte,f))
16380 {
16381 return qe_invalid;
16382 }
16383
16384 if(!p_getc(&tempbyte,f))
16385 {
16386 return qe_invalid;
16387 }
16388 }
16389 201636864 }
16390 1145664 }
16391
16392
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1142944 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1167840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16393 {
16394
2/2
✓ Branch 0 taken 1145664 times.
✓ Branch 1 taken 201636864 times.
202782528 for(int32_t k=0; k<176; k++)
16395 {
16396
16397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201636864 times.
201636864 if(!p_getc(&(temp_mapscr->cset[k]),f))
16398 {
16399 return qe_invalid;
16400 }
16401 201636864 }
16402 1145664 }
16403
16404
5/6
✓ Branch 0 taken 1145664 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1142944 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1167840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16405 {
16406 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16407 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(old_combo_pages[scrind]<<8);
16408 22176 }
16409
16410
5/6
✓ Branch 0 taken 1145664 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1142944 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1167840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16411 {
16412 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16413 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16414 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16415 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16416 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16417 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16418 22176 }
16419
16420
5/6
✓ Branch 0 taken 1145664 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1142944 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1167840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16421 {
16422
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16423 {
16424
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16425 {
16426 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16427 {
16428 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16429 }
16430 }
16431 else
16432 {
16433
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16434 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16435 {
16436 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16437 3902976 }
16438
16439 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16440 }
16441
16442 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(old_combo_pages[scrind]<<8);
16443 3902976 }
16444 22176 }
16445
16446 /*if(version>12)
16447 {
16448 if(!p_getc(&(temp_mapscr->scrWidth),f))
16449 {
16450 return qe_invalid;
16451 }
16452 if(!p_getc(&(temp_mapscr->scrHeight),f))
16453 {
16454 return qe_invalid;
16455 }
16456 }*/
16457
16458
2/2
✓ Branch 0 taken 639336 times.
✓ Branch 1 taken 528504 times.
1167840 if(version>4)
16459 {
16460
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16461 {
16462 return qe_invalid;
16463 }
16464 639336 }
16465 else
16466 {
16467 528504 temp_mapscr->screen_midi = -1;
16468 }
16469
16470
2/2
✓ Branch 0 taken 639336 times.
✓ Branch 1 taken 528504 times.
1167840 if(version>=17)
16471 {
16472
1/2
✓ Branch 0 taken 639336 times.
✗ Branch 1 not taken.
639336 if(!p_getc(&(temp_mapscr->lens_layer),f))
16473 {
16474 return qe_invalid;
16475 }
16476 639336 }
16477 else
16478 {
16479 528504 temp_mapscr->lens_layer = llNORMAL;
16480 }
16481
16482
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 639336 times.
1167840 if(version>6)
16483 {
16484 dword bits;
16485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 639336 times.
639336 if(!p_igetl(&bits,f))
16486 {
16487 return qe_invalid;
16488 }
16489
16490 int32_t m;
16491 float tempfloat;
16492 word tempw;
16493 639336 temp_mapscr->ffcCountMarkDirty();
16494 639336 temp_mapscr->ffcs.clear();
16495 639336 temp_mapscr->resizeFFC(std::bit_width(bits));
16496
2/2
✓ Branch 0 taken 639336 times.
✓ Branch 1 taken 20458752 times.
21098088 for(m=0; m<32; m++)
16497 {
16498
2/2
✓ Branch 0 taken 20194667 times.
✓ Branch 1 taken 264085 times.
20458752 if((bits>>m)&1)
16499 {
16500 264085 ffcdata& tempffc = temp_mapscr->ffcs[m];
16501
1/2
✓ Branch 0 taken 264085 times.
✗ Branch 1 not taken.
264085 if(!p_igetw(&tempw,f))
16502 {
16503 return qe_invalid;
16504 }
16505 264085 tempffc.data = tempw;
16506
16507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_getc(&(tempffc.cset),f))
16508 {
16509 return qe_invalid;
16510 }
16511
16512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetw(&(tempffc.delay),f))
16513 {
16514 return qe_invalid;
16515 }
16516
16517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(version < 9)
16518 {
16519 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16520 {
16521 return qe_invalid;
16522 }
16523
16524 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16525
16526 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16527 {
16528 return qe_invalid;
16529 }
16530
16531 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16532
16533 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16534 {
16535 return qe_invalid;
16536 }
16537
16538 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16539
16540 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16541 {
16542 return qe_invalid;
16543 }
16544
16545 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16546
16547 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16548 {
16549 return qe_invalid;
16550 }
16551
16552 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16553
16554 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16555 {
16556 return qe_invalid;
16557 }
16558
16559 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16560 }
16561 else
16562 {
16563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetzf(&(tempffc.x),f))
16564 {
16565 return qe_invalid;
16566 }
16567
16568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetzf(&(tempffc.y),f))
16569 {
16570 return qe_invalid;
16571 }
16572
16573
1/2
✓ Branch 0 taken 264085 times.
✗ Branch 1 not taken.
264085 if(!p_igetzf(&(tempffc.vx),f))
16574 {
16575 return qe_invalid;
16576 }
16577
16578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetzf(&(tempffc.vy),f))
16579 {
16580 return qe_invalid;
16581 }
16582
16583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetzf(&(tempffc.ax),f))
16584 {
16585 return qe_invalid;
16586 }
16587
16588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetzf(&(tempffc.ay),f))
16589 {
16590 return qe_invalid;
16591 }
16592 }
16593
16594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_getc(&(tempffc.link),f))
16595 {
16596 return qe_invalid;
16597 }
16598
16599
1/2
✓ Branch 0 taken 264085 times.
✗ Branch 1 not taken.
264085 if(version>7)
16600 {
16601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_getc(&tempbyte,f))
16602 {
16603 return qe_invalid;
16604 }
16605
16606 264085 tempffc.hit_width = (tempbyte&0x3F)+1;
16607 264085 tempffc.txsz = (tempbyte>>6)+1;
16608
16609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_getc(&tempbyte,f))
16610 {
16611 return qe_invalid;
16612 }
16613
16614 264085 tempffc.hit_height = (tempbyte&0x3F)+1;
16615 264085 tempffc.tysz = (tempbyte>>6)+1;
16616
16617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetl(&(tempffc.flags),f))
16618 {
16619 return qe_invalid;
16620 }
16621 264085 }
16622 else
16623 {
16624 tempffc.hit_width=16;
16625 tempffc.hit_height=16;
16626 tempffc.txsz=1;
16627 tempffc.tysz=1;
16628 tempffc.flags=ffc_none;
16629 }
16630
16631 264085 tempffc.updateSolid();
16632
16633
16634
4/6
✓ Branch 0 taken 264085 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258081 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 258081 times.
264085 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16635 {
16636 tempffc.flags|=ffc_ignoreholdup;
16637 }
16638
16639
1/2
✓ Branch 0 taken 264085 times.
✗ Branch 1 not taken.
264085 if(version>9)
16640 {
16641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetw(&(tempffc.script),f))
16642 {
16643 return qe_invalid;
16644 }
16645 264085 }
16646 else
16647 {
16648 tempffc.script=0;
16649 }
16650
16651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(version>10)
16652 {
16653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetl(&(tempffc.initd[0]),f))
16654 {
16655 return qe_invalid;
16656 }
16657
16658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetl(&(tempffc.initd[1]),f))
16659 {
16660 return qe_invalid;
16661 }
16662
16663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetl(&(tempffc.initd[2]),f))
16664 {
16665 return qe_invalid;
16666 }
16667
16668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetl(&(tempffc.initd[3]),f))
16669 {
16670 return qe_invalid;
16671 }
16672
16673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetl(&(tempffc.initd[4]),f))
16674 {
16675 return qe_invalid;
16676 }
16677
16678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetl(&(tempffc.initd[5]),f))
16679 {
16680 return qe_invalid;
16681 }
16682
16683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetl(&(tempffc.initd[6]),f))
16684 {
16685 return qe_invalid;
16686 }
16687
16688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_igetl(&(tempffc.initd[7]),f))
16689 {
16690 return qe_invalid;
16691 }
16692
16693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_getc(&(tempbyte),f))
16694 {
16695 return qe_invalid;
16696 }
16697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264085 times.
264085 if(!p_getc(&(tempbyte),f))
16698 {
16699 return qe_invalid;
16700 }
16701 264085 }
16702
16703
1/2
✓ Branch 0 taken 264085 times.
✗ Branch 1 not taken.
264085 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16704 {
16705 tempffc.script = 0;
16706 for(int q = 0; q < 8; ++q)
16707 tempffc.initd[q] = 0;
16708 }
16709
1/2
✓ Branch 0 taken 264085 times.
✗ Branch 1 not taken.
264085 if(version <= 11)
16710 {
16711 fixffcs=true;
16712 }
16713 264085 }
16714 20458752 }
16715
16716 639336 temp_mapscr->shinkToFitFFCs();
16717 639336 }
16718
16719
16720 //add in the new whistle flags
16721
2/2
✓ Branch 0 taken 639336 times.
✓ Branch 1 taken 528504 times.
1167840 if(version<13)
16722 {
16723
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16724 {
16725 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16726 124 }
16727 528504 }
16728
16729 //2.55 starts here
16730
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1133432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1167840 if ( version >= 19 && Header->zelda_version > 0x253 )
16731 {
16732 // mapscr fields that were never used, so are now removed:
16733 // int32_t npcstrings[10];
16734 // int16_t new_items[10];
16735 // int16_t new_item_x[10];
16736 // int16_t new_item_y[10];
16737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if (pack_fseek(f, 100))
16738 {
16739 return qe_invalid;
16740 }
16741 34408 }
16742
16743
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1133432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1167840 if ( version >= 20 && Header->zelda_version > 0x253 )
16744 {
16745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16746 {
16747 return qe_invalid;
16748 }
16749
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16750 {
16751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16752 {
16753 return qe_invalid;
16754 }
16755 275264 }
16756 34408 }
16757
2/2
✓ Branch 0 taken 1133432 times.
✓ Branch 1 taken 34408 times.
1167840 if ( version < 20 )
16758 {
16759 1133432 temp_mapscr->script = 0;
16760
2/2
✓ Branch 0 taken 9067456 times.
✓ Branch 1 taken 1133432 times.
10200888 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16761 1133432 }
16762
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1133432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1167840 if ( version >= 21 && Header->zelda_version > 0x253 )
16763 {
16764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16765 {
16766 return qe_invalid;
16767 }
16768 34408 }
16769
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1133432 times.
1167840 if ( version < 21 )
16770 {
16771 1133432 temp_mapscr->preloadscript = 0;
16772 1133432 }
16773
16774
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1133432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1167840 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16775 {
16776
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16777 {
16778 return qe_invalid;
16779 }
16780
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16781 {
16782 return qe_invalid;
16783 }
16784 34408 }
16785
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1133432 times.
1167840 if ( version < 22 )
16786 {
16787 1133432 temp_mapscr->hidelayers = 0;
16788 1133432 temp_mapscr->hidescriptlayers = 0;
16789 1133432 }
16790
16791 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16792 //May be any version before 2.11. -Z
16793 /* --not the roar, the HIT SFX
16794 if ( Header->zelda_version <= 0x210 )
16795 {
16796 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16797 {
16798 temp_mapscr->bosssfx = WAV_ROAR;
16799 }
16800 }
16801 */
16802
2/2
✓ Branch 0 taken 4671360 times.
✓ Branch 1 taken 1167840 times.
5839200 for(int32_t k=0; k<4; k++)
16803 {
16804
1/2
✓ Branch 0 taken 4671360 times.
✗ Branch 1 not taken.
4671360 if(temp_mapscr->door[k] == dNONE)
16805 temp_mapscr->door[k] = dWALL;
16806 4671360 }
16807
16808 1167840 return 0;
16809 1167840 }
16810 1365992 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16811 {
16812
2/2
✓ Branch 0 taken 1167840 times.
✓ Branch 1 taken 198152 times.
1365992 if(version < 23)
16813 {
16814 1167840 auto ret = readmapscreen_old(f,Header,temp_mapscr,version,scrind);
16815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1167840 times.
1167840 if(ret) return ret;
16816 1167840 }
16817 else
16818 {
16819
1/2
✓ Branch 0 taken 198152 times.
✗ Branch 1 not taken.
198152 if(!p_getc(&(temp_mapscr->valid),f))
16820 return qe_invalid;
16821
2/2
✓ Branch 0 taken 105170 times.
✓ Branch 1 taken 92982 times.
198152 if(!(temp_mapscr->valid & mVALID))
16822 {
16823 92982 int map = scrind/MAPSCRS;
16824 92982 int screen = scrind%MAPSCRS;
16825
4/6
✓ Branch 0 taken 85880 times.
✓ Branch 1 taken 7102 times.
✓ Branch 2 taken 85880 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 85880 times.
92982 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16826 {
16827 //Empty screen, apply autolayers
16828
2/2
✓ Branch 0 taken 515280 times.
✓ Branch 1 taken 85880 times.
601160 for(int q = 0; q < 6; ++q)
16829 {
16830 515280 auto layermap = map_autolayers[map*6+q];
16831 515280 temp_mapscr->layermap[q] = layermap;
16832
2/2
✓ Branch 0 taken 500124 times.
✓ Branch 1 taken 15156 times.
515280 if(layermap)
16833 15156 temp_mapscr->layerscreen[q] = screen;
16834 515280 }
16835 85880 }
16836 92982 return 0;
16837 }
16838 uint32_t scr_has_flags;
16839
1/2
✓ Branch 0 taken 105170 times.
✗ Branch 1 not taken.
105170 if(!p_igetl(&scr_has_flags,f))
16840 return qe_invalid;
16841
16842
2/2
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 94712 times.
105170 if(scr_has_flags & SCRHAS_ROOMDATA)
16843 {
16844
1/2
✓ Branch 0 taken 94712 times.
✗ Branch 1 not taken.
94712 if(!p_getc(&(temp_mapscr->guy),f))
16845 return qe_invalid;
16846
2/2
✓ Branch 0 taken 94592 times.
✓ Branch 1 taken 120 times.
94712 if(version > 26)
16847 {
16848
1/2
✓ Branch 0 taken 94592 times.
✗ Branch 1 not taken.
94592 if(!p_igetl(&(temp_mapscr->guytile),f))
16849 return qe_invalid;
16850
1/2
✓ Branch 0 taken 94592 times.
✗ Branch 1 not taken.
94592 if(!p_getc(&(temp_mapscr->guycs),f))
16851 return qe_invalid;
16852
1/2
✓ Branch 0 taken 94592 times.
✗ Branch 1 not taken.
94592 if(!p_igetw(&(temp_mapscr->roomflags),f))
16853 return qe_invalid;
16854 94592 }
16855 else
16856 {
16857 120 temp_mapscr->guytile = -1; //signal to use default guy values
16858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16859
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16860 }
16861
1/2
✓ Branch 0 taken 94712 times.
✗ Branch 1 not taken.
94712 if(!p_igetw(&(temp_mapscr->str),f))
16862 return qe_invalid;
16863
1/2
✓ Branch 0 taken 94712 times.
✗ Branch 1 not taken.
94712 if(!p_getc(&(temp_mapscr->room),f))
16864 return qe_invalid;
16865
1/2
✓ Branch 0 taken 94712 times.
✗ Branch 1 not taken.
94712 if(!p_igetw(&(temp_mapscr->catchall),f))
16866 return qe_invalid;
16867 94712 }
16868
2/2
✓ Branch 0 taken 102832 times.
✓ Branch 1 taken 2338 times.
105170 if(scr_has_flags & SCRHAS_ITEM)
16869 {
16870
1/2
✓ Branch 0 taken 2338 times.
✗ Branch 1 not taken.
2338 if(!p_getc(&(temp_mapscr->item),f))
16871 return qe_invalid;
16872
1/2
✓ Branch 0 taken 2338 times.
✗ Branch 1 not taken.
2338 if(!p_getc(&(temp_mapscr->hasitem),f))
16873 return qe_invalid;
16874
1/2
✓ Branch 0 taken 2338 times.
✗ Branch 1 not taken.
2338 if(!p_getc(&(temp_mapscr->itemx),f))
16875 return qe_invalid;
16876
1/2
✓ Branch 0 taken 2338 times.
✗ Branch 1 not taken.
2338 if(!p_getc(&(temp_mapscr->itemy),f))
16877 return qe_invalid;
16878 2338 }
16879
2/2
✓ Branch 0 taken 94541 times.
✓ Branch 1 taken 10629 times.
105170 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16880 {
16881
1/2
✓ Branch 0 taken 10629 times.
✗ Branch 1 not taken.
10629 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16882 return qe_invalid;
16883 10629 }
16884
2/2
✓ Branch 0 taken 102702 times.
✓ Branch 1 taken 2468 times.
105170 if(scr_has_flags & SCRHAS_TWARP)
16885 {
16886
2/2
✓ Branch 0 taken 9872 times.
✓ Branch 1 taken 2468 times.
12340 for(int32_t i=0; i<4; i++)
16887 {
16888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9872 times.
9872 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16889 return qe_invalid;
16890 9872 }
16891
2/2
✓ Branch 0 taken 9872 times.
✓ Branch 1 taken 2468 times.
12340 for(int32_t i=0; i<4; i++)
16892 {
16893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9872 times.
9872 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16894 return qe_invalid;
16895 9872 }
16896
2/2
✓ Branch 0 taken 9872 times.
✓ Branch 1 taken 2468 times.
12340 for(int32_t i=0; i<4; i++)
16897 {
16898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9872 times.
9872 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16899 return qe_invalid;
16900 9872 }
16901
1/2
✓ Branch 0 taken 2468 times.
✗ Branch 1 not taken.
2468 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16902 return qe_invalid;
16903 2468 }
16904
2/2
✓ Branch 0 taken 96535 times.
✓ Branch 1 taken 8635 times.
105170 if(scr_has_flags & SCRHAS_SWARP)
16905 {
16906
2/2
✓ Branch 0 taken 34540 times.
✓ Branch 1 taken 8635 times.
43175 for(int32_t i=0; i<4; i++)
16907 {
16908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34540 times.
34540 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16909 return qe_invalid;
16910 34540 }
16911
2/2
✓ Branch 0 taken 34540 times.
✓ Branch 1 taken 8635 times.
43175 for(int32_t i=0; i<4; i++)
16912 {
16913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34540 times.
34540 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16914 return qe_invalid;
16915 34540 }
16916
2/2
✓ Branch 0 taken 34540 times.
✓ Branch 1 taken 8635 times.
43175 for(int32_t i=0; i<4; i++)
16917 {
16918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34540 times.
34540 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16919 return qe_invalid;
16920 34540 }
16921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8635 times.
8635 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16922 return qe_invalid;
16923
1/2
✓ Branch 0 taken 8635 times.
✗ Branch 1 not taken.
8635 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16924 return qe_invalid;
16925 8635 }
16926
2/2
✓ Branch 0 taken 98793 times.
✓ Branch 1 taken 6377 times.
105170 if(scr_has_flags & SCRHAS_WARPRET)
16927 {
16928
2/2
✓ Branch 0 taken 25508 times.
✓ Branch 1 taken 6377 times.
31885 for(int32_t i=0; i<4; i++)
16929 {
16930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25508 times.
25508 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16931 return qe_invalid;
16932 25508 }
16933
2/2
✓ Branch 0 taken 25508 times.
✓ Branch 1 taken 6377 times.
31885 for(int32_t i=0; i<4; i++)
16934 {
16935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25508 times.
25508 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16936 return qe_invalid;
16937 25508 }
16938
1/2
✓ Branch 0 taken 6377 times.
✗ Branch 1 not taken.
6377 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16939 return qe_invalid;
16940
1/2
✓ Branch 0 taken 6377 times.
✗ Branch 1 not taken.
6377 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16941 return qe_invalid;
16942 6377 }
16943
2/2
✓ Branch 0 taken 91687 times.
✓ Branch 1 taken 13483 times.
105170 if(scr_has_flags & SCRHAS_LAYERS)
16944 {
16945
2/2
✓ Branch 0 taken 80898 times.
✓ Branch 1 taken 13483 times.
94381 for(int32_t k=0; k<6; k++)
16946 {
16947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80898 times.
80898 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16948 return qe_invalid;
16949 80898 }
16950
2/2
✓ Branch 0 taken 80898 times.
✓ Branch 1 taken 13483 times.
94381 for(int32_t k=0; k<6; k++)
16951 {
16952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80898 times.
80898 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16953 return qe_invalid;
16954 80898 }
16955
2/2
✓ Branch 0 taken 80898 times.
✓ Branch 1 taken 13483 times.
94381 for(int32_t k=0; k<6; k++)
16956 {
16957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80898 times.
80898 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16958 return qe_invalid;
16959 80898 }
16960
1/2
✓ Branch 0 taken 13483 times.
✗ Branch 1 not taken.
13483 if(!p_getc(&(temp_mapscr->hidelayers),f))
16961 return qe_invalid;
16962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13483 times.
13483 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16963 return qe_invalid;
16964 13483 }
16965
2/2
✓ Branch 0 taken 105066 times.
✓ Branch 1 taken 104 times.
105170 if(scr_has_flags & SCRHAS_MAZE)
16966 {
16967
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
520 for(int32_t k=0; k<4; k++)
16968 {
16969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(!p_getc(&(temp_mapscr->path[k]),f))
16970 return qe_invalid;
16971 416 }
16972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_getc(&(temp_mapscr->exitdir),f))
16973 return qe_invalid;
16974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (version >= 32)
16975 {
16976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (!p_getc(&temp_mapscr->maze_transition_wipe, f))
16977 return qe_invalid;
16978 104 }
16979 104 }
16980
2/2
✓ Branch 0 taken 76908 times.
✓ Branch 1 taken 28262 times.
105170 if(scr_has_flags & SCRHAS_D_S_U)
16981 {
16982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76908 times.
76908 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16983 return qe_invalid;
16984
2/2
✓ Branch 0 taken 307632 times.
✓ Branch 1 taken 76908 times.
384540 for(int32_t k=0; k<4; k++)
16985 {
16986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 307632 times.
307632 if(!p_getc(&(temp_mapscr->door[k]),f))
16987 return qe_invalid;
16988
3/4
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 307272 times.
✓ Branch 2 taken 360 times.
✗ Branch 3 not taken.
307632 if(version < 29 && temp_mapscr->door[k] == dNONE)
16989 temp_mapscr->door[k] = dWALL;
16990 307632 }
16991
16992
1/2
✓ Branch 0 taken 76908 times.
✗ Branch 1 not taken.
76908 if(!p_getc(&(temp_mapscr->stairx),f))
16993 return qe_invalid;
16994
16995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76908 times.
76908 if(!p_getc(&(temp_mapscr->stairy),f))
16996 return qe_invalid;
16997
1/2
✓ Branch 0 taken 76908 times.
✗ Branch 1 not taken.
76908 if(!p_igetw(&(temp_mapscr->undercombo),f))
16998 return qe_invalid;
16999
1/2
✓ Branch 0 taken 76908 times.
✗ Branch 1 not taken.
76908 if(!p_getc(&(temp_mapscr->undercset),f))
17000 return qe_invalid;
17001 76908 }
17002
2/2
✓ Branch 0 taken 10488 times.
✓ Branch 1 taken 17774 times.
28262 else if(version < 29)
17003 {
17004
2/2
✓ Branch 0 taken 41952 times.
✓ Branch 1 taken 10488 times.
52440 for(int k = 0; k < 4; ++k)
17005 41952 temp_mapscr->door[k] = dWALL;
17006 10488 }
17007
2/2
✓ Branch 0 taken 98749 times.
✓ Branch 1 taken 6421 times.
105170 if(scr_has_flags & SCRHAS_FLAGS)
17008 {
17009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6421 times.
6421 if(!p_getc(&(temp_mapscr->flags),f))
17010 return qe_invalid;
17011
1/2
✓ Branch 0 taken 6421 times.
✗ Branch 1 not taken.
6421 if(!p_getc(&(temp_mapscr->flags2),f))
17012 return qe_invalid;
17013
1/2
✓ Branch 0 taken 6421 times.
✗ Branch 1 not taken.
6421 if(!p_getc(&(temp_mapscr->flags3),f))
17014 return qe_invalid;
17015
1/2
✓ Branch 0 taken 6421 times.
✗ Branch 1 not taken.
6421 if(!p_getc(&(temp_mapscr->flags4),f))
17016 return qe_invalid;
17017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6421 times.
6421 if(!p_getc(&(temp_mapscr->flags5),f))
17018 return qe_invalid;
17019
1/2
✓ Branch 0 taken 6421 times.
✗ Branch 1 not taken.
6421 if(!p_getc(&(temp_mapscr->flags6),f))
17020 return qe_invalid;
17021
1/2
✓ Branch 0 taken 6421 times.
✗ Branch 1 not taken.
6421 if(!p_getc(&(temp_mapscr->flags7),f))
17022 return qe_invalid;
17023
1/2
✓ Branch 0 taken 6421 times.
✗ Branch 1 not taken.
6421 if(!p_getc(&(temp_mapscr->flags8),f))
17024 return qe_invalid;
17025
1/2
✓ Branch 0 taken 6421 times.
✗ Branch 1 not taken.
6421 if(!p_getc(&(temp_mapscr->flags9),f))
17026 return qe_invalid;
17027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6421 times.
6421 if(!p_getc(&(temp_mapscr->flags10),f))
17028 return qe_invalid;
17029
1/2
✓ Branch 0 taken 6421 times.
✗ Branch 1 not taken.
6421 if(!p_getc(&(temp_mapscr->flags11),f))
17030 return qe_invalid;
17031 6421 }
17032
2/2
✓ Branch 0 taken 99910 times.
✓ Branch 1 taken 5260 times.
105170 if(scr_has_flags & SCRHAS_ENEMY)
17033 {
17034
2/2
✓ Branch 0 taken 52600 times.
✓ Branch 1 taken 5260 times.
57860 for(int32_t k=0; k<10; k++)
17035 {
17036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52600 times.
52600 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17037 return qe_invalid;
17038
1/2
✓ Branch 0 taken 52600 times.
✗ Branch 1 not taken.
52600 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17039 temp_mapscr->enemy[k] = 0;
17040 52600 }
17041
1/2
✓ Branch 0 taken 5260 times.
✗ Branch 1 not taken.
5260 if(!p_getc(&(temp_mapscr->pattern),f))
17042 return qe_invalid;
17043 5260 }
17044
2/2
✓ Branch 0 taken 104765 times.
✓ Branch 1 taken 405 times.
105170 if(scr_has_flags & SCRHAS_CARRY)
17045 {
17046
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_igetw(&(temp_mapscr->noreset),f))
17047 return qe_invalid;
17048
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_igetw(&(temp_mapscr->nocarry),f))
17049 return qe_invalid;
17050
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&(temp_mapscr->nextmap),f))
17051 return qe_invalid;
17052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405 times.
405 if(!p_getc(&(temp_mapscr->nextscr),f))
17053 return qe_invalid;
17054 405 }
17055
2/2
✓ Branch 0 taken 104603 times.
✓ Branch 1 taken 567 times.
105170 if(scr_has_flags & SCRHAS_SCRIPT)
17056 {
17057
1/2
✓ Branch 0 taken 567 times.
✗ Branch 1 not taken.
567 if(!p_igetw(&(temp_mapscr->script),f))
17058 return qe_invalid;
17059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 567 times.
567 if(!p_getc(&(temp_mapscr->preloadscript),f))
17060 return qe_invalid;
17061
2/2
✓ Branch 0 taken 4536 times.
✓ Branch 1 taken 567 times.
5103 for ( int32_t q = 0; q < 8; q++ )
17062 {
17063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4536 times.
4536 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17064 return qe_invalid;
17065 4536 }
17066 567 }
17067
2/2
✓ Branch 0 taken 73749 times.
✓ Branch 1 taken 31421 times.
105170 if(scr_has_flags & SCRHAS_SECRETS)
17068 {
17069
2/2
✓ Branch 0 taken 4021888 times.
✓ Branch 1 taken 31421 times.
4053309 for(int32_t k=0; k<128; k++)
17070 {
17071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4021888 times.
4021888 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17072 return qe_invalid;
17073 4021888 }
17074
2/2
✓ Branch 0 taken 4021888 times.
✓ Branch 1 taken 31421 times.
4053309 for(int32_t k=0; k<128; k++)
17075 {
17076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4021888 times.
4021888 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17077 return qe_invalid;
17078 4021888 }
17079
2/2
✓ Branch 0 taken 4021888 times.
✓ Branch 1 taken 31421 times.
4053309 for(int32_t k=0; k<128; k++)
17080 {
17081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4021888 times.
4021888 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17082 return qe_invalid;
17083 4021888 }
17084 31421 }
17085
2/2
✓ Branch 0 taken 40658 times.
✓ Branch 1 taken 64512 times.
105170 if(scr_has_flags & SCRHAS_COMBOFLAG)
17086 {
17087
2/2
✓ Branch 0 taken 11354112 times.
✓ Branch 1 taken 64512 times.
11418624 for(int32_t k=0; k<176; ++k)
17088 {
17089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11354112 times.
11354112 if(!p_igetw(&(temp_mapscr->data[k]),f))
17090 return qe_invalid;
17091 11354112 }
17092
2/2
✓ Branch 0 taken 11354112 times.
✓ Branch 1 taken 64512 times.
11418624 for(int32_t k=0; k<176; ++k)
17093 {
17094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11354112 times.
11354112 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17095 return qe_invalid;
17096 11354112 }
17097
2/2
✓ Branch 0 taken 11354112 times.
✓ Branch 1 taken 64512 times.
11418624 for(int32_t k=0; k<176; ++k)
17098 {
17099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11354112 times.
11354112 if(!p_getc(&(temp_mapscr->cset[k]),f))
17100 return qe_invalid;
17101 11354112 }
17102 64512 }
17103
1/2
✓ Branch 0 taken 105170 times.
✗ Branch 1 not taken.
105170 if(scr_has_flags & SCRHAS_MISC)
17104 {
17105
1/2
✓ Branch 0 taken 105170 times.
✗ Branch 1 not taken.
105170 if(!p_igetw(&(temp_mapscr->color),f))
17106 return qe_invalid;
17107
1/2
✓ Branch 0 taken 105170 times.
✗ Branch 1 not taken.
105170 if(!p_getc(&(temp_mapscr->csensitive),f))
17108 return qe_invalid;
17109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105170 times.
105170 if(!p_getc(&(temp_mapscr->oceansfx),f))
17110 return qe_invalid;
17111
1/2
✓ Branch 0 taken 105170 times.
✗ Branch 1 not taken.
105170 if(!p_getc(&(temp_mapscr->bosssfx),f))
17112 return qe_invalid;
17113
1/2
✓ Branch 0 taken 105170 times.
✗ Branch 1 not taken.
105170 if(!p_getc(&(temp_mapscr->secretsfx),f))
17114 return qe_invalid;
17115
1/2
✓ Branch 0 taken 105170 times.
✗ Branch 1 not taken.
105170 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17116 return qe_invalid;
17117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105170 times.
105170 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17118 return qe_invalid;
17119
1/2
✓ Branch 0 taken 105170 times.
✗ Branch 1 not taken.
105170 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17120 return qe_invalid;
17121
1/2
✓ Branch 0 taken 105170 times.
✗ Branch 1 not taken.
105170 if(!p_getc(&(temp_mapscr->lens_layer),f))
17122 return qe_invalid;
17123
2/2
✓ Branch 0 taken 10578 times.
✓ Branch 1 taken 94592 times.
105170 if(version > 27)
17124 {
17125
1/2
✓ Branch 0 taken 94592 times.
✗ Branch 1 not taken.
94592 if(!p_getc(&(temp_mapscr->lens_show),f))
17126 return qe_invalid;
17127
1/2
✓ Branch 0 taken 94592 times.
✗ Branch 1 not taken.
94592 if(!p_getc(&(temp_mapscr->lens_hide),f))
17128 return qe_invalid;
17129 94592 }
17130 105170 }
17131 else
17132 {
17133 temp_mapscr->screen_midi = -1;
17134 temp_mapscr->csensitive = 1;
17135 }
17136 //FFC
17137 105170 bool old_ff = version < 25;
17138 105170 dword bits = 0;
17139 105170 word numffc = 32;
17140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105170 times.
105170 if(old_ff)
17141 {
17142 if(!p_igetl(&bits,f))
17143 return qe_invalid;
17144 }
17145 else
17146 {
17147
2/4
✓ Branch 0 taken 105170 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 105170 times.
105170 if(!p_igetw(&numffc,f) || numffc > MAXFFCS)
17148 return qe_invalid;
17149 }
17150
17151 105170 temp_mapscr->ffcCountMarkDirty();
17152 105170 temp_mapscr->ffcs.clear();
17153 105170 temp_mapscr->resizeFFC(numffc);
17154
17155 byte tempbyte;
17156 word tempw;
17157
4/6
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 105023 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 147 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 147 times.
105170 static ffcdata nil_ffc;
17158
2/2
✓ Branch 0 taken 1981321 times.
✓ Branch 1 taken 105170 times.
2086491 for(word m = 0; m < numffc; ++m)
17159 {
17160
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1981321 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1981321 if(old_ff && !(bits & (1<<m))) continue;
17161
17162
1/2
✓ Branch 0 taken 1981321 times.
✗ Branch 1 not taken.
1981321 ffcdata& tempffc = (m < MAXFFCS)
17163 1981321 ? temp_mapscr->ffcs[m]
17164 : nil_ffc; //sanity
17165
17166
1/2
✓ Branch 0 taken 1981321 times.
✗ Branch 1 not taken.
1981321 if(!p_igetw(&tempw,f))
17167 return qe_invalid;
17168
3/4
✓ Branch 0 taken 1981321 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13913 times.
✓ Branch 3 taken 1967408 times.
1981321 if(!old_ff && !tempw) //empty ffc, nothing more to load
17169 1967408 continue;
17170 13913 tempffc.data = tempw;
17171
17172
1/2
✓ Branch 0 taken 13913 times.
✗ Branch 1 not taken.
13913 if(!p_getc(&(tempffc.cset),f))
17173 return qe_invalid;
17174
1/2
✓ Branch 0 taken 13913 times.
✗ Branch 1 not taken.
13913 if(!p_igetw(&(tempffc.delay),f))
17175 return qe_invalid;
17176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13913 times.
13913 if(!p_igetzf(&(tempffc.x),f))
17177 return qe_invalid;
17178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13913 times.
13913 if(!p_igetzf(&(tempffc.y),f))
17179 return qe_invalid;
17180
1/2
✓ Branch 0 taken 13913 times.
✗ Branch 1 not taken.
13913 if(!p_igetzf(&(tempffc.vx),f))
17181 return qe_invalid;
17182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13913 times.
13913 if(!p_igetzf(&(tempffc.vy),f))
17183 return qe_invalid;
17184
1/2
✓ Branch 0 taken 13913 times.
✗ Branch 1 not taken.
13913 if(!p_igetzf(&(tempffc.ax),f))
17185 return qe_invalid;
17186
1/2
✓ Branch 0 taken 13913 times.
✗ Branch 1 not taken.
13913 if(!p_igetzf(&(tempffc.ay),f))
17187 return qe_invalid;
17188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13913 times.
13913 if(!p_getc(&(tempffc.link),f))
17189 return qe_invalid;
17190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13913 times.
13913 if(version < 24)
17191 {
17192 if(!p_getc(&tempbyte,f))
17193 return qe_invalid;
17194 tempffc.hit_width = (tempbyte&0x3F)+1;
17195 tempffc.txsz = (tempbyte>>6)+1;
17196 if(!p_getc(&tempbyte,f))
17197 return qe_invalid;
17198 tempffc.hit_height = (tempbyte&0x3F)+1;
17199 tempffc.tysz = (tempbyte>>6)+1;
17200 }
17201 else
17202 {
17203
1/2
✓ Branch 0 taken 13913 times.
✗ Branch 1 not taken.
13913 if(!p_igetl(&(tempffc.hit_width),f))
17204 return qe_invalid;
17205
1/2
✓ Branch 0 taken 13913 times.
✗ Branch 1 not taken.
13913 if(!p_igetl(&(tempffc.hit_height),f))
17206 return qe_invalid;
17207
1/2
✓ Branch 0 taken 13913 times.
✗ Branch 1 not taken.
13913 if(!p_getc(&(tempffc.txsz),f))
17208 return qe_invalid;
17209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13913 times.
13913 if(!p_getc(&(tempffc.tysz),f))
17210 return qe_invalid;
17211 }
17212
1/2
✓ Branch 0 taken 13913 times.
✗ Branch 1 not taken.
13913 if(!p_igetl(&(tempffc.flags),f))
17213 return qe_invalid;
17214 13913 tempffc.updateSolid();
17215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13913 times.
13913 if(!p_igetw(&(tempffc.script),f))
17216 return qe_invalid;
17217
2/2
✓ Branch 0 taken 111304 times.
✓ Branch 1 taken 13913 times.
125217 for(auto q = 0; q < 8; ++q)
17218 {
17219
1/2
✓ Branch 0 taken 111304 times.
✗ Branch 1 not taken.
111304 if(!p_igetl(&(tempffc.initd[q]),f))
17220 return qe_invalid;
17221 111304 }
17222
2/2
✓ Branch 0 taken 8011 times.
✓ Branch 1 taken 5902 times.
13913 if(version < 33)
17223 {
17224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17225 return qe_invalid;
17226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17227 return qe_invalid;
17228 8011 }
17229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5902 times.
5902 else if(!p_getc(&(tempffc.layer),f))
17230 return qe_invalid;
17231
17232
1/2
✓ Branch 0 taken 13913 times.
✗ Branch 1 not taken.
13913 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17233 {
17234 tempffc.script = 0;
17235 for(int q = 0; q < 8; ++q)
17236 tempffc.initd[q] = 0;
17237 }
17238 13913 }
17239 //END FFC
17240
2/2
✓ Branch 0 taken 38497 times.
✓ Branch 1 taken 66673 times.
105170 if(version > 29)
17241
1/2
✓ Branch 0 taken 66673 times.
✗ Branch 1 not taken.
66673 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17242 return qe_invalid;
17243 }
17244
17245 1273010 temp_mapscr->shinkToFitFFCs();
17246
17247 1273010 return 0;
17248 1365992 }
17249
17250 467 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17251 {
17252
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 24 times.
467 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17253 467 int32_t screen=0;
17254
17255 467 word version=0;
17256 dword dummy;
17257 int32_t screens_to_read;
17258
17259 467 mapscr temp_mapscr{};
17260 word temp_map_count;
17261 dword section_size;
17262
17263
5/6
✓ Branch 0 taken 449 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 443 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
467 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17264 {
17265 18 screens_to_read=MAPSCRS192b136;
17266 18 }
17267 else
17268 {
17269 449 screens_to_read=MAPSCRS;
17270 }
17271
17272
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 24 times.
467 if(Header->zelda_version > 0x192)
17273 {
17274 //section version info
17275
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&version,f))
17276 {
17277 return qe_invalid;
17278 }
17279
17280 443 FFCore.quest_format[vMaps] = version;
17281
17282
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&dummy,f))
17283 {
17284 return qe_invalid;
17285 }
17286
17287 //section size
17288
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetl(&section_size,f))
17289 {
17290 return qe_invalid;
17291 }
17292
17293 //finally... section data
17294
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&temp_map_count,f))
17295 {
17296 return 5;
17297 }
17298 443 }
17299 else
17300 {
17301 24 temp_map_count=map_count;
17302 }
17303
17304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if (temp_map_count > MAXMAPS)
17305 {
17306 return qe_invalid;
17307 }
17308
17309
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 1 times.
467 if (!should_skip)
17310 {
17311 466 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17312 466 TheMaps.clear();
17313
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 TheMaps.resize(_mapsSize);
17314 466 old_combo_pages.clear();
17315
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 old_combo_pages.resize(_mapsSize);
17316 466 map_autolayers.clear();
17317
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 map_autolayers.resize(temp_map_count*6);
17318
2/2
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 135 times.
466 if(version >= 31)
17319 135 Regions = {};
17320 466 }
17321
17322
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 10182 times.
✓ Branch 2 taken 10182 times.
✓ Branch 3 taken 467 times.
10649 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17323 {
17324 10182 byte valid=1;
17325
2/2
✓ Branch 0 taken 1590 times.
✓ Branch 1 taken 8592 times.
10182 if(version > 22)
17326 {
17327
2/4
✓ Branch 0 taken 1590 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1590 times.
✗ Branch 3 not taken.
1590 if(!p_getc(&valid,f))
17328 return qe_invalid;
17329 1590 }
17330
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 10049 times.
10182 if(valid)
17331 {
17332
2/2
✓ Branch 0 taken 8722 times.
✓ Branch 1 taken 1327 times.
10049 if (version > 25)
17333 {
17334
2/2
✓ Branch 0 taken 7962 times.
✓ Branch 1 taken 1327 times.
9289 for(int q = 0; q < 6; ++q)
17335 {
17336
2/4
✓ Branch 0 taken 7962 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7962 times.
✗ Branch 3 not taken.
7962 if(!p_igetw(&map_autolayers[i*6+q],f))
17337 return qe_invalid;
17338 7962 }
17339 1327 }
17340
17341
2/2
✓ Branch 0 taken 9164 times.
✓ Branch 1 taken 885 times.
10049 if (version >= 31)
17342 {
17343 static regions_data tmp_rd;
17344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 885 times.
885 regions_data& rd = should_skip ? tmp_rd : Regions[i];
17345
2/2
✓ Branch 0 taken 7080 times.
✓ Branch 1 taken 885 times.
7965 for(int32_t j=0; j<8; j++)
17346 {
17347
2/2
✓ Branch 0 taken 56640 times.
✓ Branch 1 taken 7080 times.
63720 for(int32_t k=0; k<8; k++)
17348 {
17349
2/4
✓ Branch 0 taken 56640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56640 times.
✗ Branch 3 not taken.
56640 if(!p_getc(&rd.region_ids[j][k],f))
17350 {
17351 return qe_invalid;
17352 }
17353 56640 }
17354 7080 }
17355 885 }
17356 10049 }
17357
2/2
✓ Branch 0 taken 1384080 times.
✓ Branch 1 taken 10182 times.
1394262 for(int32_t j=0; j<screens_to_read; j++)
17358 {
17359 1384080 screen=i*MAPSCRS+j;
17360
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1383808 times.
1384080 mapscr* scr = should_skip ? &temp_mapscr : &TheMaps[screen];
17361 1384080 scr->map = i;
17362 1384080 scr->screen = j;
17363
2/2
✓ Branch 0 taken 1365992 times.
✓ Branch 1 taken 18088 times.
1384080 if(valid)
17364
1/2
✓ Branch 0 taken 1365992 times.
✗ Branch 1 not taken.
1365992 readmapscreen(f, Header, scr, version, screen);
17365
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 else if (!should_skip)
17366
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 clear_screen(scr);
17367 1384080 }
17368
17369
2/2
✓ Branch 0 taken 10180 times.
✓ Branch 1 taken 2 times.
10182 if (should_skip)
17370 2 continue;
17371
17372
5/6
✓ Branch 0 taken 10012 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9994 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10180 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17373 {
17374 168 int32_t index = (i*MAPSCRS+132);
17375
17376
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17377
17378 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17379 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17380 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17381
17382
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17383 {
17384 504 screen=i*MAPSCRS+j;
17385
17386
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[screen].zero_memory();
17387 504 TheMaps[screen].valid = mVERSION;
17388 504 TheMaps[screen].screen_midi = -1;
17389 504 TheMaps[screen].csensitive = 1;
17390 504 }
17391 168 }
17392
17393
5/6
✓ Branch 0 taken 10012 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9994 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10180 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17394 {
17395
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17396 {
17397 22848 screen=i*MAPSCRS+j;
17398
1/2
✓ Branch 0 taken 22848 times.
✗ Branch 1 not taken.
22848 TheMaps[screen].door_combo_set=MakeDoors(i, j);
17399
17400
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17401 {
17402
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcset[k]=tcmbcset2(i, TheMaps[screen].secretcombo[k]);
17403
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretflag[k]=tcmbflag2(i, TheMaps[screen].secretcombo[k]);
17404
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcombo[k]=tcmbdat2(i, j, TheMaps[screen].secretcombo[k]);
17405 2924544 }
17406 22848 }
17407 168 }
17408 10180 }
17409 467 map_count = temp_map_count;
17410 467 return 0;
17411 467 }
17412
17413
17414 8971159 void update_combo(newcombo& cmb, word section_version)
17415 {
17416
2/2
✓ Branch 0 taken 1208269 times.
✓ Branch 1 taken 7762890 times.
8971159 if(section_version < 40)
17417 {
17418
3/3
✓ Branch 0 taken 5094 times.
✓ Branch 1 taken 45446 times.
✓ Branch 2 taken 7712350 times.
7762890 switch(cmb.type)
17419 {
17420 case cWATER: case cSHALLOWWATER:
17421 45446 cmb.attribytes[6] = iwRipples;
17422 45446 break;
17423 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17424 5094 cmb.attribytes[6] = iwTallGrass;
17425 5094 break;
17426 }
17427 7762890 }
17428
2/2
✓ Branch 0 taken 860838 times.
✓ Branch 1 taken 8110321 times.
8971159 if(section_version < 49)
17429 {
17430
4/4
✓ Branch 0 taken 8075344 times.
✓ Branch 1 taken 34977 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 8060067 times.
8110321 if(cmb.type == cWATER || cmb.type == cSHALLOWWATER)
17431 50254 cmb.sfx_landing = WAV_ZN1SPLASH;
17432 8110321 }
17433 8971159 }
17434 292 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17435 {
17436
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 24 times.
292 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17437
17438
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 291 times.
292 if (!should_skip)
17439 {
17440 291 reset_all_combo_animations();
17441 291 init_combo_classes();
17442 291 }
17443
17444 // combos
17445 292 word combos_used=0;
17446 int32_t dummy;
17447 byte padding;
17448 292 newcombo temp_combo;
17449
17450
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 291 times.
292 if (!should_skip)
17451
2/2
✓ Branch 0 taken 18996480 times.
✓ Branch 1 taken 291 times.
18996771 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17452
1/2
✓ Branch 0 taken 18996480 times.
✗ Branch 1 not taken.
18996771 combobuf[q].clear();
17453
17454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
292 if(version < 0x174)
17455 {
17456 combos_used=1024;
17457 }
17458
2/2
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 18 times.
292 else if(version < 0x191)
17459 {
17460 18 combos_used=2048;
17461 18 }
17462 else
17463 {
17464
2/4
✓ Branch 0 taken 274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 274 times.
✗ Branch 3 not taken.
274 if(!p_igetw(&combos_used,f))
17465 {
17466 return qe_invalid;
17467 }
17468 }
17469
17470 //finally... section data
17471
2/2
✓ Branch 0 taken 7627874 times.
✓ Branch 1 taken 292 times.
7628166 for(int32_t i=0; i<combos_used; i++)
17472 {
17473
1/2
✓ Branch 0 taken 7627874 times.
✗ Branch 1 not taken.
7627874 temp_combo.clear();
17474
17475
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7424906 times.
7627874 if ( section_version >= 11 )
17476 {
17477
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17478 {
17479 return qe_invalid;
17480 }
17481 202968 }
17482 else
17483 {
17484
2/4
✓ Branch 0 taken 7424906 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7424906 times.
✗ Branch 3 not taken.
7424906 if(!p_igetw(&temp_combo.tile,f))
17485 {
17486 return qe_invalid;
17487 }
17488 }
17489 7627874 temp_combo.o_tile = temp_combo.tile;
17490
2/4
✓ Branch 0 taken 7627874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7627874 times.
✗ Branch 3 not taken.
7627874 if(!p_getc(&temp_combo.flip,f))
17491 {
17492 return qe_invalid;
17493 }
17494
17495
2/4
✓ Branch 0 taken 7627874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7627874 times.
✗ Branch 3 not taken.
7627874 if(!p_getc(&temp_combo.walk,f))
17496 {
17497 return qe_invalid;
17498 }
17499
17500
2/4
✓ Branch 0 taken 7627874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7627874 times.
✗ Branch 3 not taken.
7627874 if(!p_getc(&temp_combo.type,f))
17501 {
17502 return qe_invalid;
17503 }
17504
17505
2/4
✓ Branch 0 taken 7627874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7627874 times.
✗ Branch 3 not taken.
7627874 if(!p_getc(&temp_combo.csets,f))
17506 {
17507 return qe_invalid;
17508 }
17509
17510
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7558100 times.
7627874 if(version < 0x193)
17511 {
17512
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17513 return qe_invalid;
17514
17515
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17516 return qe_invalid;
17517
17518
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17519 {
17520
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17521 {
17522 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17523 {
17524 if(!p_getc(&padding,f))
17525 return qe_invalid;
17526 }
17527 }
17528 36864 }
17529 69774 }
17530
2/2
✓ Branch 0 taken 7591010 times.
✓ Branch 1 taken 36864 times.
7627874 if(version >= 0x192)
17531 {
17532
2/4
✓ Branch 0 taken 7591010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7591010 times.
✗ Branch 3 not taken.
7591010 if(!p_getc(&temp_combo.frames,f))
17533 return qe_invalid;
17534
17535
2/4
✓ Branch 0 taken 7591010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7591010 times.
✗ Branch 3 not taken.
7591010 if(!p_getc(&temp_combo.speed,f))
17536 return qe_invalid;
17537
17538
2/4
✓ Branch 0 taken 7591010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7591010 times.
✗ Branch 3 not taken.
7591010 if(!p_igetw(&temp_combo.nextcombo,f))
17539 return qe_invalid;
17540
17541
2/4
✓ Branch 0 taken 7591010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7591010 times.
✗ Branch 3 not taken.
7591010 if(!p_getc(&temp_combo.nextcset,f))
17542 return qe_invalid;
17543
17544 //Base flag
17545
2/2
✓ Branch 0 taken 4702602 times.
✓ Branch 1 taken 2888408 times.
7591010 if(section_version>=3)
17546
2/4
✓ Branch 0 taken 4702602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4702602 times.
✗ Branch 3 not taken.
4702602 if(!p_getc(&temp_combo.flag,f))
17547 return qe_invalid;
17548
17549
2/2
✓ Branch 0 taken 4702602 times.
✓ Branch 1 taken 2888408 times.
7591010 if(section_version>=4)
17550 {
17551
2/4
✓ Branch 0 taken 4702602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4702602 times.
✗ Branch 3 not taken.
4702602 if(!p_getc(&temp_combo.skipanim,f))
17552 return qe_invalid;
17553
17554
2/4
✓ Branch 0 taken 4702602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4702602 times.
✗ Branch 3 not taken.
4702602 if(!p_igetw(&temp_combo.nexttimer,f))
17555 return qe_invalid;
17556 4702602 }
17557
17558
2/2
✓ Branch 0 taken 4702602 times.
✓ Branch 1 taken 2888408 times.
7591010 if(section_version>=5)
17559
2/4
✓ Branch 0 taken 4702602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4702602 times.
✗ Branch 3 not taken.
4702602 if(!p_getc(&temp_combo.skipanimy,f))
17560 return qe_invalid;
17561
17562
2/2
✓ Branch 0 taken 4702602 times.
✓ Branch 1 taken 2888408 times.
7591010 if(section_version>=6)
17563 {
17564
2/4
✓ Branch 0 taken 4702602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4702602 times.
✗ Branch 3 not taken.
4702602 if(!p_getc(&temp_combo.animflags,f))
17565 return qe_invalid;
17566
17567
1/2
✓ Branch 0 taken 4702602 times.
✗ Branch 1 not taken.
4702602 if(section_version == 6)
17568 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17569 4702602 }
17570
17571
2/2
✓ Branch 0 taken 7388042 times.
✓ Branch 1 taken 202968 times.
7591010 if(section_version>=8) //combo Attributes[4] and userflags.
17572 {
17573
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17574
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17575 return qe_invalid;
17576
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17577 return qe_invalid;
17578
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17579
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17580 return qe_invalid;
17581 202968 }
17582
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7388042 times.
7591010 if(section_version>=10) //combo trigger flags
17583 {
17584
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17585
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_combo.triggerflags[q],f))
17586 return qe_invalid;
17587 202968 }
17588
1/2
✓ Branch 0 taken 7388042 times.
✗ Branch 1 not taken.
7388042 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17589 {
17590 for ( int32_t q = 0; q < 2; q++ )
17591 if(!p_igetl(&temp_combo.triggerflags[q],f))
17592 return qe_invalid;
17593 }
17594
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7388042 times.
7591010 if(section_version >= 9)
17595
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.triggerlevel,f))
17596 return qe_invalid;
17597
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7388042 times.
7591010 if(section_version >= 22)
17598
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.triggerbtn,f))
17599 return qe_invalid;
17600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7591010 times.
7591010 if(section_version >= 24)
17601 {
17602 if(!p_getc(&temp_combo.triggeritem,f))
17603 return qe_invalid;
17604 if(!p_getc(&temp_combo.trigtimer,f))
17605 return qe_invalid;
17606 }
17607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7591010 times.
7591010 if(section_version >= 25)
17608 if(!p_getc(&temp_combo.trigsfx,f))
17609 return qe_invalid;
17610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7591010 times.
7591010 if(section_version >= 27)
17611 if(!p_igetl(&temp_combo.trigchange,f))
17612 return qe_invalid;
17613
17614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7591010 times.
7591010 if(section_version >= 29)
17615 {
17616 if(!p_igetw(&temp_combo.trigprox,f))
17617 return qe_invalid;
17618 if(!p_getc(&temp_combo.trigctr,f))
17619 return qe_invalid;
17620 if(!p_igetl(&temp_combo.trigctramnt,f))
17621 return qe_invalid;
17622 }
17623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7591010 times.
7591010 if(section_version >= 30)
17624 if(!p_getc(&temp_combo.triglbeam,f))
17625 return qe_invalid;
17626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7591010 times.
7591010 if(section_version >= 31)
17627 {
17628 if(!p_getc(&temp_combo.trigcschange,f))
17629 return qe_invalid;
17630 if(!p_igetw(&temp_combo.spawnitem,f))
17631 return qe_invalid;
17632 if(!p_igetw(&temp_combo.spawnenemy,f))
17633 return qe_invalid;
17634 if(!p_getc(&temp_combo.exstate,f))
17635 return qe_invalid;
17636 if(!p_igetl(&temp_combo.spawnip,f))
17637 return qe_invalid;
17638 if(!p_getc(&temp_combo.trigcopycat,f))
17639 return qe_invalid;
17640 }
17641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7591010 times.
7591010 if(section_version >= 32)
17642 if(!p_getc(&temp_combo.trigcooldown,f))
17643 return qe_invalid;
17644
17645
2/2
✓ Branch 0 taken 7388042 times.
✓ Branch 1 taken 202968 times.
7591010 if(section_version>=12) //combo label
17646 {
17647 char label[12];
17648 202968 label[11] = '\0';
17649
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17650
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17651 return qe_invalid;
17652
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17653 202968 }
17654
2/2
✓ Branch 0 taken 7388042 times.
✓ Branch 1 taken 202968 times.
7591010 if(section_version>=13) //attribytes[4]
17655
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17656
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17657 202968 return qe_invalid;
17658 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17659 * This fixes a poor implementation of a ->next flag bug thing.
17660 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17661 * there was a version bump a few weeks before a change that broke stuff.
17662 */
17663
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7388042 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7591010 if (section_version >= 13 && section_version < 21)
17664 {
17665 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17666 }
17667 //combo scripts
17668
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7388042 times.
7591010 if(section_version>=14)
17669 {
17670
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17671 return qe_invalid;
17672
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17673
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17674 return qe_invalid;
17675 202968 }
17676
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7388042 times.
7591010 if(section_version>=15)
17677 {
17678
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17679
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17680
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17681
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17682 202968 }
17683
2/2
✓ Branch 0 taken 7388042 times.
✓ Branch 1 taken 202968 times.
7591010 if(section_version>=17) //attribytes[4]
17684 {
17685
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17686
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17687 return qe_invalid;
17688
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17689
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17690 return qe_invalid;
17691 202968 }
17692
17693
2/2
✓ Branch 0 taken 7558100 times.
✓ Branch 1 taken 32910 times.
7591010 if(version < 0x193)
17694
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17695
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17696 32910 return qe_invalid;
17697 7591010 }
17698
17699 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17700
3/6
✓ Branch 0 taken 4702602 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4702602 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7627874 if((version < 0x211)||((version == 0x211)&&(build<7)))
17701 {
17702
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
17703 {
17704
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17705 {
17706 case 130:
17707 temp_combo.tile = 132;
17708 break;
17709
17710 case 131:
17711 temp_combo.tile = 133;
17712 break;
17713
17714 case 132:
17715 temp_combo.tile = 130;
17716 break;
17717
17718 case 133:
17719 temp_combo.tile = 131;
17720 break;
17721 }
17722 39936 }
17723 2925272 }
17724
17725
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7424906 times.
7627874 if(section_version < 15)
17726 7424906 temp_combo.o_tile = temp_combo.tile;
17727
17728
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7424906 times.
7627874 if(section_version<18) //upper bits for .walk
17729 7424906 temp_combo.walk |= 0xF0;
17730
17731
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7424906 times.
7627874 if(section_version < 19)
17732
2/2
✓ Branch 0 taken 29699624 times.
✓ Branch 1 taken 7424906 times.
37124530 for(int32_t q = 0; q < 4; ++q)
17733 37124530 temp_combo.attributes[q] *= 10000L;
17734
17735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7627874 times.
7627874 if(section_version < 23)
17736 {
17737
2/2
✓ Branch 0 taken 15123 times.
✓ Branch 1 taken 7612751 times.
7627874 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17738 {
17739 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17740 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17741 case cTRIGGERGENERIC: case cCSWITCH:
17742 15123 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17743 15123 }
17744 7627874 }
17745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7627874 times.
7627874 if(section_version < 25)
17746 {
17747
2/2
✓ Branch 0 taken 27587 times.
✓ Branch 1 taken 7600287 times.
7627874 switch(temp_combo.type)
17748 {
17749 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27587 times.
27587 if(!(temp_combo.usrflags & cflag3))
17751 27587 temp_combo.attribytes[3] = WAV_DOOR;
17752 27587 temp_combo.usrflags &= ~cflag3;
17753 27587 break;
17754 }
17755 7627874 }
17756
17757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7627874 times.
7627874 if(section_version < 26)
17758
2/2
✓ Branch 0 taken 7626732 times.
✓ Branch 1 taken 1142 times.
7629016 if(temp_combo.type == cARMOS)
17759
1/2
✓ Branch 0 taken 1142 times.
✗ Branch 1 not taken.
1142 if(temp_combo.usrflags & cflag1)
17760 temp_combo.usrflags |= cflag3;
17761
17762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7627874 times.
7627874 if(section_version < 27)
17763 {
17764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7627874 times.
7627874 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17765 temp_combo.trigchange = 1;
17766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7627874 times.
7627874 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17767 temp_combo.trigchange = -1;
17768 7627874 else temp_combo.trigchange = 0;
17769 7627874 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17770 7627874 }
17771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7627874 times.
7627874 if(section_version < 28)
17772 {
17773
2/2
✓ Branch 0 taken 15656 times.
✓ Branch 1 taken 7612218 times.
7627874 switch(temp_combo.type)
17774 {
17775 case cLOCKBLOCK: case cLOCKEDCHEST:
17776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15656 times.
15656 if(temp_combo.usrflags & cflag7)
17777 temp_combo.usrflags |= cflag8;
17778 15656 else temp_combo.usrflags &= ~cflag8;
17779 15656 temp_combo.usrflags &= ~cflag7;
17780 15656 break;
17781 }
17782
2/2
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 7627092 times.
7627874 switch(temp_combo.type)
17783 {
17784 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17785 782 temp_combo.attrishorts[2] = -1;
17786 782 temp_combo.usrflags |= cflag7;
17787 782 break;
17788 }
17789 7627874 }
17790
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7424906 times.
7627874 if(section_version < 20)
17791 {
17792 7424906 temp_combo.genflags = 0;
17793
2/2
✓ Branch 0 taken 144574 times.
✓ Branch 1 taken 7280332 times.
7424906 switch(temp_combo.type)
17794 {
17795 case cPUSH_WAIT: case cPUSH_HEAVY:
17796 case cPUSH_HW: case cL_STATUE:
17797 case cR_STATUE: case cPUSH_HEAVY2:
17798 case cPUSH_HW2: case cPOUND:
17799 case cC_STATUE: case cMIRROR:
17800 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17801 case cMAGICPRISM: case cMAGICPRISM4:
17802 case cMAGICSPONGE: case cEYEBALL_A:
17803 case cEYEBALL_B: case cEYEBALL_4:
17804 case cBUSH: case cFLOWERS:
17805 case cLOCKBLOCK: case cLOCKBLOCK2:
17806 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17807 case cCHEST: case cCHEST2:
17808 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17809 case cBOSSCHEST: case cBOSSCHEST2:
17810 case cBUSHNEXT: case cBUSHTOUCHY:
17811 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17812 case cSIGNPOST: case cCSWITCHBLOCK:
17813 case cTORCH: case cTRIGGERGENERIC:
17814
1/2
✓ Branch 0 taken 144574 times.
✗ Branch 1 not taken.
144574 if(temp_combo.usrflags & cflag16)
17815 {
17816 temp_combo.genflags |= cflag1;
17817 temp_combo.usrflags &= ~cflag16;
17818 }
17819 144574 break;
17820 }
17821 7424906 }
17822
17823 7627874 update_combo(temp_combo, section_version);
17824
17825
3/4
✓ Branch 0 taken 7627874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7612955 times.
✓ Branch 3 taken 14919 times.
7627874 if(i>=start_combo && !should_skip)
17826 {
17827
1/2
✓ Branch 0 taken 7612955 times.
✗ Branch 1 not taken.
7612955 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17828 {
17829 temp_combo.script = 0;
17830 for(int q = 0; q < 8; ++q)
17831 temp_combo.initd[q] = 0;
17832 }
17833
1/2
✓ Branch 0 taken 7612955 times.
✗ Branch 1 not taken.
7612955 combobuf[i] = temp_combo;
17834 7612955 }
17835 7627874 }
17836
17837
2/2
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 1 times.
292 if (should_skip)
17838 1 return 0;
17839
17840
5/6
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 268 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
291 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17841 {
17842
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17843 {
17844
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17845 {
17846 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17847 215 }
17848 1501440 }
17849 23 }
17850
17851 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17852
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 232 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
291 if(version == 0x210 && get_app_id() != App::zquest)
17853 {
17854
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17855
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
17856 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17857 59 }
17858
17859
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 82 times.
291 if(section_version<7)
17860 {
17861
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17862 {
17863
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
17864 {
17865 case cSLASH:
17866 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
17867 853 break;
17868
17869 case cSLASHITEM:
17870 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17871 791 break;
17872
17873 case cBUSH:
17874 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
17875 603 break;
17876
17877 case cFLOWERS:
17878 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17879 174 break;
17880
17881 case cTALLGRASS:
17882 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17883 531 break;
17884
17885 case cSLASHNEXT:
17886 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17887 break;
17888
17889 case cSLASHNEXTITEM:
17890 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17891 break;
17892
17893 case cBUSHNEXT:
17894 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17895 break;
17896 }
17897 5352960 }
17898 82 }
17899
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 286 times.
291 if (section_version < 16)
17900 {
17901
2/2
✓ Branch 0 taken 18670080 times.
✓ Branch 1 taken 286 times.
18670366 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17902 {
17903
2/2
✓ Branch 0 taken 18641033 times.
✓ Branch 1 taken 29047 times.
18670080 if (combobuf[tmpcounter].type == cWATER)
17904 {
17905 29047 combobuf[tmpcounter].attributes[0] = 40000L;
17906 29047 }
17907 18670080 }
17908 286 }
17909
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 3 times.
291 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17910 {
17911 3 combobuf[0].walk = 0xF0;
17912 3 combobuf[0].type = 0;
17913 3 combobuf[0].flag = 0;
17914 3 }
17915
17916 //Now for the new combo alias reset
17917
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 82 times.
291 if(section_version<2)
17918 {
17919
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17920 {
17921 671744 combo_aliases[j].width = 0;
17922 671744 combo_aliases[j].height = 0;
17923 671744 combo_aliases[j].layermask = 0;
17924
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
17925
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
17926 671744 }
17927 82 }
17928
17929
17930
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 setup_combo_animations();
17931
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 setup_combo_animations2();
17932 291 return 0;
17933 292 }
17934 1343285 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
17935 {
17936 byte combo_has_flags;
17937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1343285 times.
1343285 if(!p_getc(&combo_has_flags,f))
17938 return qe_invalid;
17939
17940 1343285 temp_combo.clear();
17941
2/2
✓ Branch 0 taken 707495 times.
✓ Branch 1 taken 635790 times.
1343285 if(combo_has_flags)
17942 {
17943
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 635733 times.
635790 if(combo_has_flags&CHAS_BASIC)
17944 {
17945
1/2
✓ Branch 0 taken 635733 times.
✗ Branch 1 not taken.
635733 if(!p_igetl(&temp_combo.tile,f))
17946 return qe_invalid;
17947 635733 temp_combo.o_tile = temp_combo.tile;
17948
17949
1/2
✓ Branch 0 taken 635733 times.
✗ Branch 1 not taken.
635733 if(!p_getc(&temp_combo.flip,f))
17950 return qe_invalid;
17951
17952
1/2
✓ Branch 0 taken 635733 times.
✗ Branch 1 not taken.
635733 if(!p_getc(&temp_combo.walk,f))
17953 return qe_invalid;
17954
17955
1/2
✓ Branch 0 taken 635733 times.
✗ Branch 1 not taken.
635733 if(!p_getc(&temp_combo.type,f))
17956 return qe_invalid;
17957
17958
1/2
✓ Branch 0 taken 635733 times.
✗ Branch 1 not taken.
635733 if(!p_getc(&temp_combo.flag,f))
17959 return qe_invalid;
17960
17961
1/2
✓ Branch 0 taken 635733 times.
✗ Branch 1 not taken.
635733 if(!p_getc(&temp_combo.csets,f))
17962 return qe_invalid;
17963 635733 }
17964
2/2
✓ Branch 0 taken 632966 times.
✓ Branch 1 taken 2824 times.
635790 if(combo_has_flags&CHAS_SCRIPT)
17965 {
17966
2/2
✓ Branch 0 taken 2794 times.
✓ Branch 1 taken 30 times.
2824 if (s_version>=41)
17967 {
17968 2794 p_getcstr(&temp_combo.label, f);
17969 2794 }
17970 else
17971 {
17972 char label[12];
17973 30 label[11] = '\0';
17974
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
17975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330 times.
330 if(!p_getc(&label[q],f))
17976 return qe_invalid;
17977 30 temp_combo.label = label;
17978 }
17979
17980
1/2
✓ Branch 0 taken 2824 times.
✗ Branch 1 not taken.
2824 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
17981 2824 auto initd_count = s_version >= 43 ? 8 : 2;
17982
2/2
✓ Branch 0 taken 22412 times.
✓ Branch 1 taken 2824 times.
25236 for ( int32_t q = 0; q < initd_count; q++ )
17983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22412 times.
22412 if(!p_igetl(&temp_combo.initd[q],f))
17984 return qe_invalid;
17985 2824 }
17986
2/2
✓ Branch 0 taken 513536 times.
✓ Branch 1 taken 122254 times.
635790 if(combo_has_flags&CHAS_ANIM)
17987 {
17988
1/2
✓ Branch 0 taken 122254 times.
✗ Branch 1 not taken.
122254 if(!p_getc(&temp_combo.frames,f))
17989 return qe_invalid;
17990
17991
1/2
✓ Branch 0 taken 122254 times.
✗ Branch 1 not taken.
122254 if(!p_getc(&temp_combo.speed,f))
17992 return qe_invalid;
17993
17994
1/2
✓ Branch 0 taken 122254 times.
✗ Branch 1 not taken.
122254 if(!p_igetw(&temp_combo.nextcombo,f))
17995 return qe_invalid;
17996
17997
1/2
✓ Branch 0 taken 122254 times.
✗ Branch 1 not taken.
122254 if(!p_getc(&temp_combo.nextcset,f))
17998 return qe_invalid;
17999
18000
1/2
✓ Branch 0 taken 122254 times.
✗ Branch 1 not taken.
122254 if(!p_getc(&temp_combo.skipanim,f))
18001 return qe_invalid;
18002
18003
1/2
✓ Branch 0 taken 122254 times.
✗ Branch 1 not taken.
122254 if(!p_getc(&temp_combo.skipanimy,f))
18004 return qe_invalid;
18005
18006
1/2
✓ Branch 0 taken 122254 times.
✗ Branch 1 not taken.
122254 if(!p_getc(&temp_combo.animflags,f))
18007 return qe_invalid;
18008 122254 }
18009
2/2
✓ Branch 0 taken 584390 times.
✓ Branch 1 taken 51400 times.
635790 if(combo_has_flags&CHAS_ATTRIB)
18010 {
18011
2/2
✓ Branch 0 taken 205600 times.
✓ Branch 1 taken 51400 times.
257000 for ( int32_t q = 0; q < 4; q++ )
18012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205600 times.
205600 if(!p_igetl(&temp_combo.attributes[q],f))
18013 return qe_invalid;
18014
2/2
✓ Branch 0 taken 411200 times.
✓ Branch 1 taken 51400 times.
462600 for ( int32_t q = 0; q < 8; q++ )
18015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411200 times.
411200 if(!p_getc(&temp_combo.attribytes[q],f))
18016 return qe_invalid;
18017
2/2
✓ Branch 0 taken 411200 times.
✓ Branch 1 taken 51400 times.
462600 for ( int32_t q = 0; q < 8; q++ )
18018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411200 times.
411200 if(!p_igetw(&temp_combo.attrishorts[q],f))
18019 return qe_invalid;
18020 51400 }
18021
2/2
✓ Branch 0 taken 624978 times.
✓ Branch 1 taken 10812 times.
635790 if(combo_has_flags&CHAS_FLAG)
18022 {
18023
1/2
✓ Branch 0 taken 10812 times.
✗ Branch 1 not taken.
10812 if(!p_igetl(&temp_combo.usrflags,f))
18024 return qe_invalid;
18025
1/2
✓ Branch 0 taken 10812 times.
✗ Branch 1 not taken.
10812 if(!p_igetw(&temp_combo.genflags,f))
18026 return qe_invalid;
18027 10812 }
18028
2/2
✓ Branch 0 taken 623818 times.
✓ Branch 1 taken 11972 times.
635790 if(combo_has_flags&CHAS_TRIG)
18029 {
18030 11972 int numtrigs = s_version < 36 ? 3 : 6;
18031
2/2
✓ Branch 0 taken 70974 times.
✓ Branch 1 taken 11972 times.
82946 for ( int32_t q = 0; q < numtrigs; q++ )
18032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70974 times.
70974 if(!p_igetl(&temp_combo.triggerflags[q],f))
18033 return qe_invalid;
18034
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_igetl(&temp_combo.triggerlevel,f))
18035 return qe_invalid;
18036
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_getc(&temp_combo.triggerbtn,f))
18037 return qe_invalid;
18038
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_getc(&temp_combo.triggeritem,f))
18039 return qe_invalid;
18040
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_getc(&temp_combo.trigtimer,f))
18041 return qe_invalid;
18042
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_getc(&temp_combo.trigsfx,f))
18043 return qe_invalid;
18044
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_igetl(&temp_combo.trigchange,f))
18045 return qe_invalid;
18046
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_igetw(&temp_combo.trigprox,f))
18047 return qe_invalid;
18048
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_getc(&temp_combo.trigctr,f))
18049 return qe_invalid;
18050
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_igetl(&temp_combo.trigctramnt,f))
18051 return qe_invalid;
18052
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_getc(&temp_combo.triglbeam,f))
18053 return qe_invalid;
18054
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_getc(&temp_combo.trigcschange,f))
18055 return qe_invalid;
18056
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_igetw(&temp_combo.spawnitem,f))
18057 return qe_invalid;
18058
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_igetw(&temp_combo.spawnenemy,f))
18059 return qe_invalid;
18060
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_getc(&temp_combo.exstate,f))
18061 return qe_invalid;
18062
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_igetl(&temp_combo.spawnip,f))
18063 return qe_invalid;
18064
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_getc(&temp_combo.trigcopycat,f))
18065 return qe_invalid;
18066
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_getc(&temp_combo.trigcooldown,f))
18067 return qe_invalid;
18068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11972 times.
11972 if(s_version >= 35)
18069 {
18070
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_igetw(&temp_combo.prompt_cid,f))
18071 return qe_invalid;
18072
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_getc(&temp_combo.prompt_cs,f))
18073 return qe_invalid;
18074
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_igetw(&temp_combo.prompt_x,f))
18075 return qe_invalid;
18076
1/2
✓ Branch 0 taken 11972 times.
✗ Branch 1 not taken.
11972 if(!p_igetw(&temp_combo.prompt_y,f))
18077 return qe_invalid;
18078 11972 }
18079
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 11686 times.
11972 if(s_version >= 36)
18080 {
18081
1/2
✓ Branch 0 taken 11686 times.
✗ Branch 1 not taken.
11686 if(!p_getc(&temp_combo.trig_lstate,f))
18082 return qe_invalid;
18083
1/2
✓ Branch 0 taken 11686 times.
✗ Branch 1 not taken.
11686 if(!p_getc(&temp_combo.trig_gstate,f))
18084 return qe_invalid;
18085
1/2
✓ Branch 0 taken 11686 times.
✗ Branch 1 not taken.
11686 if(!p_igetl(&temp_combo.trig_statetime,f))
18086 return qe_invalid;
18087 11686 }
18088
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 11686 times.
11972 if(s_version >= 37)
18089 {
18090
1/2
✓ Branch 0 taken 11686 times.
✗ Branch 1 not taken.
11686 if(!p_igetw(&temp_combo.trig_genscr,f))
18091 return qe_invalid;
18092 11686 }
18093
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 11538 times.
11972 if(s_version >= 38)
18094 {
18095
1/2
✓ Branch 0 taken 11538 times.
✗ Branch 1 not taken.
11538 if(!p_getc(&temp_combo.trig_group,f))
18096 return qe_invalid;
18097
1/2
✓ Branch 0 taken 11538 times.
✗ Branch 1 not taken.
11538 if(!p_igetw(&temp_combo.trig_group_val,f))
18098 return qe_invalid;
18099 11538 }
18100
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 11502 times.
11972 if(s_version >= 45)
18101 {
18102
1/2
✓ Branch 0 taken 11502 times.
✗ Branch 1 not taken.
11502 if(!p_getc(&temp_combo.exdoor_dir,f))
18103 return qe_invalid;
18104
1/2
✓ Branch 0 taken 11502 times.
✗ Branch 1 not taken.
11502 if(!p_getc(&temp_combo.exdoor_ind,f))
18105 return qe_invalid;
18106 11502 }
18107
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 4860 times.
11972 if(s_version >= 46)
18108 {
18109
1/2
✓ Branch 0 taken 4860 times.
✗ Branch 1 not taken.
4860 if(!p_getc(&temp_combo.trig_levelitems,f))
18110 return qe_invalid;
18111
1/2
✓ Branch 0 taken 4860 times.
✗ Branch 1 not taken.
4860 if(!p_igetw(&temp_combo.trigdmlevel,f))
18112 return qe_invalid;
18113
1/2
✓ Branch 0 taken 4860 times.
✗ Branch 1 not taken.
4860 if(s_version >= 48)
18114 {
18115
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 4860 times.
19440 for(int q = 0; q < 3; ++q)
18116
1/2
✓ Branch 0 taken 14580 times.
✗ Branch 1 not taken.
14580 if(!p_igetw(&temp_combo.trigtint[q],f))
18117 return qe_invalid;
18118 4860 }
18119 else
18120 {
18121 for(int q = 0; q < 3; ++q)
18122 if(!p_getc(&temp_combo.trigtint[q],f))
18123 return qe_invalid;
18124 for(int q = 0; q < 3; ++q)
18125 {
18126 int v = temp_combo.trigtint[q];
18127 int va = abs(v);
18128 temp_combo.trigtint[q] = _rgb_scale_6[va] * sign(v);
18129 }
18130 }
18131
1/2
✓ Branch 0 taken 4860 times.
✗ Branch 1 not taken.
4860 if(!p_igetw(&temp_combo.triglvlpalette,f))
18132 return qe_invalid;
18133
1/2
✓ Branch 0 taken 4860 times.
✗ Branch 1 not taken.
4860 if(!p_igetw(&temp_combo.trigbosspalette,f))
18134 return qe_invalid;
18135
1/2
✓ Branch 0 taken 4860 times.
✗ Branch 1 not taken.
4860 if(!p_igetw(&temp_combo.trigquaketime,f))
18136 return qe_invalid;
18137
1/2
✓ Branch 0 taken 4860 times.
✗ Branch 1 not taken.
4860 if(!p_igetw(&temp_combo.trigwavytime,f))
18138 return qe_invalid;
18139
1/2
✓ Branch 0 taken 4860 times.
✗ Branch 1 not taken.
4860 if(!p_igetw(&temp_combo.trig_swjinxtime,f))
18140 return qe_invalid;
18141
1/2
✓ Branch 0 taken 4860 times.
✗ Branch 1 not taken.
4860 if(!p_igetw(&temp_combo.trig_itmjinxtime,f))
18142 return qe_invalid;
18143
1/2
✓ Branch 0 taken 4860 times.
✗ Branch 1 not taken.
4860 if(!p_igetw(&temp_combo.trig_stuntime,f))
18144 return qe_invalid;
18145
1/2
✓ Branch 0 taken 4860 times.
✗ Branch 1 not taken.
4860 if(!p_igetw(&temp_combo.trig_bunnytime,f))
18146 return qe_invalid;
18147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4860 times.
4860 if(!p_getc(&temp_combo.trig_pushtime,f))
18148 return qe_invalid;
18149 4860 }
18150
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 4860 times.
11972 if(s_version >= 47)
18151 {
18152
1/2
✓ Branch 0 taken 4860 times.
✗ Branch 1 not taken.
4860 if (!p_igetw(&temp_combo.trig_shieldjinxtime, f))
18153 return qe_invalid;
18154 4860 }
18155 11972 }
18156
2/2
✓ Branch 0 taken 635285 times.
✓ Branch 1 taken 505 times.
635790 if(combo_has_flags&CHAS_LIFT)
18157 {
18158
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_igetw(&temp_combo.liftcmb,f))
18159 return qe_invalid;
18160
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_getc(&temp_combo.liftcs,f))
18161 return qe_invalid;
18162
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_igetw(&temp_combo.liftundercmb,f))
18163 return qe_invalid;
18164
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_getc(&temp_combo.liftundercs,f))
18165 return qe_invalid;
18166
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_getc(&temp_combo.liftdmg,f))
18167 return qe_invalid;
18168
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_getc(&temp_combo.liftlvl,f))
18169 return qe_invalid;
18170
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_getc(&temp_combo.liftitm,f))
18171 return qe_invalid;
18172
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_getc(&temp_combo.liftflags,f))
18173 return qe_invalid;
18174
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_getc(&temp_combo.liftgfx,f))
18175 return qe_invalid;
18176
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_getc(&temp_combo.liftsprite,f))
18177 return qe_invalid;
18178
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_getc(&temp_combo.liftsfx,f))
18179 return qe_invalid;
18180
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18181 return qe_invalid;
18182
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_getc(&temp_combo.liftbreaksfx,f))
18183 return qe_invalid;
18184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 505 times.
505 if(s_version >= 34)
18185 {
18186
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_getc(&temp_combo.lifthei,f))
18187 return qe_invalid;
18188
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if(!p_getc(&temp_combo.lifttime,f))
18189 return qe_invalid;
18190 505 }
18191
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 491 times.
505 if(s_version >= 39)
18192 {
18193
1/2
✓ Branch 0 taken 491 times.
✗ Branch 1 not taken.
491 if(!p_getc(&temp_combo.lift_parent_item,f))
18194 return qe_invalid;
18195 491 }
18196 505 }
18197
2/2
✓ Branch 0 taken 605958 times.
✓ Branch 1 taken 29832 times.
635790 if(combo_has_flags&CHAS_GENERAL)
18198 {
18199
1/2
✓ Branch 0 taken 29832 times.
✗ Branch 1 not taken.
29832 if(!p_getc(&temp_combo.speed_mult,f))
18200 return qe_invalid;
18201
1/2
✓ Branch 0 taken 29832 times.
✗ Branch 1 not taken.
29832 if(!p_getc(&temp_combo.speed_div,f))
18202 return qe_invalid;
18203
1/2
✓ Branch 0 taken 29832 times.
✗ Branch 1 not taken.
29832 if(!p_igetzf(&temp_combo.speed_add,f))
18204 return qe_invalid;
18205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29832 times.
29832 if(s_version >= 42)
18206 {
18207
1/2
✓ Branch 0 taken 29832 times.
✗ Branch 1 not taken.
29832 if(!p_getc(&temp_combo.sfx_appear,f))
18208 return qe_invalid;
18209
1/2
✓ Branch 0 taken 29832 times.
✗ Branch 1 not taken.
29832 if(!p_getc(&temp_combo.sfx_disappear,f))
18210 return qe_invalid;
18211
1/2
✓ Branch 0 taken 29832 times.
✗ Branch 1 not taken.
29832 if(!p_getc(&temp_combo.sfx_loop,f))
18212 return qe_invalid;
18213
1/2
✓ Branch 0 taken 29832 times.
✗ Branch 1 not taken.
29832 if(!p_getc(&temp_combo.sfx_walking,f))
18214 return qe_invalid;
18215
1/2
✓ Branch 0 taken 29832 times.
✗ Branch 1 not taken.
29832 if(!p_getc(&temp_combo.sfx_standing,f))
18216 return qe_invalid;
18217
1/2
✓ Branch 0 taken 29832 times.
✗ Branch 1 not taken.
29832 if(!p_getc(&temp_combo.spr_appear,f))
18218 return qe_invalid;
18219
1/2
✓ Branch 0 taken 29832 times.
✗ Branch 1 not taken.
29832 if(!p_getc(&temp_combo.spr_disappear,f))
18220 return qe_invalid;
18221
1/2
✓ Branch 0 taken 29832 times.
✗ Branch 1 not taken.
29832 if(!p_getc(&temp_combo.spr_walking,f))
18222 return qe_invalid;
18223
1/2
✓ Branch 0 taken 29832 times.
✗ Branch 1 not taken.
29832 if(!p_getc(&temp_combo.spr_standing,f))
18224 return qe_invalid;
18225 29832 }
18226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29832 times.
29832 if(s_version >= 44)
18227 {
18228
1/2
✓ Branch 0 taken 29832 times.
✗ Branch 1 not taken.
29832 if(!p_getc(&temp_combo.sfx_tap,f))
18229 return qe_invalid;
18230 29832 }
18231
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 29466 times.
29832 if(s_version >= 49)
18232 {
18233
1/2
✓ Branch 0 taken 29466 times.
✗ Branch 1 not taken.
29466 if(!p_getc(&temp_combo.sfx_landing,f))
18234 return qe_invalid;
18235 29466 }
18236
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 29466 times.
29832 if(s_version >= 50)
18237 {
18238
1/2
✓ Branch 0 taken 29466 times.
✗ Branch 1 not taken.
29466 if(!p_getc(&temp_combo.spr_falling,f))
18239 return qe_invalid;
18240
1/2
✓ Branch 0 taken 29466 times.
✗ Branch 1 not taken.
29466 if(!p_getc(&temp_combo.spr_drowning,f))
18241 return qe_invalid;
18242
1/2
✓ Branch 0 taken 29466 times.
✗ Branch 1 not taken.
29466 if(!p_getc(&temp_combo.spr_lava_drowning,f))
18243 return qe_invalid;
18244
1/2
✓ Branch 0 taken 29466 times.
✗ Branch 1 not taken.
29466 if(!p_getc(&temp_combo.sfx_falling,f))
18245 return qe_invalid;
18246
1/2
✓ Branch 0 taken 29466 times.
✗ Branch 1 not taken.
29466 if(!p_getc(&temp_combo.sfx_drowning,f))
18247 return qe_invalid;
18248
1/2
✓ Branch 0 taken 29466 times.
✗ Branch 1 not taken.
29466 if(!p_getc(&temp_combo.sfx_lava_drowning,f))
18249 return qe_invalid;
18250 29466 }
18251 29832 }
18252 635790 }
18253 1343285 update_combo(temp_combo, s_version);
18254 1343285 return 0;
18255 1343285 }
18256
18257 467 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18258 {
18259
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 24 times.
467 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18260
18261 467 word section_version=0;
18262 467 word combos_used=0;
18263 int32_t dummy;
18264 byte padding;
18265 467 newcombo temp_combo;
18266
18267
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 466 times.
467 if (!should_skip)
18268 {
18269
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 reset_all_combo_animations();
18270
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 init_combo_classes();
18271
18272
2/2
✓ Branch 0 taken 30420480 times.
✓ Branch 1 taken 466 times.
30420946 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18273
1/2
✓ Branch 0 taken 30420480 times.
✗ Branch 1 not taken.
30420480 combobuf[q].clear();
18274 466 }
18275
18276
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 24 times.
467 if(version > 0x192) //Version info
18277 {
18278
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&section_version,f))
18279 {
18280 return qe_invalid;
18281 }
18282 443 FFCore.quest_format[vCombos] = section_version;
18283
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!read_deprecated_section_cversion(f))
18284 {
18285 return qe_invalid;
18286 }
18287
18288 //section size
18289
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetl(&dummy,f))
18290 {
18291 return qe_invalid;
18292 }
18293 443 }
18294
18295
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 292 times.
467 if(section_version > 32) //Cleanup time!
18296 {
18297
2/4
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 if(!p_igetw(&combos_used,f))
18298 {
18299 return qe_invalid;
18300 }
18301
2/2
✓ Branch 0 taken 1343285 times.
✓ Branch 1 taken 175 times.
1343460 for(int32_t i=0; i<combos_used; i++)
18302 {
18303
1/2
✓ Branch 0 taken 1343285 times.
✗ Branch 1 not taken.
1343285 auto ret = readcombo_loop(f,section_version,temp_combo);
18304
1/2
✓ Branch 0 taken 1343285 times.
✗ Branch 1 not taken.
1343285 if(ret) return ret;
18305
1/2
✓ Branch 0 taken 1343285 times.
✗ Branch 1 not taken.
1343285 if(i>=start_combo)
18306 {
18307
1/2
✓ Branch 0 taken 1343285 times.
✗ Branch 1 not taken.
1343285 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18308 {
18309 temp_combo.script = 0;
18310 for(int q = 0; q < 8; ++q)
18311 temp_combo.initd[q] = 0;
18312 }
18313
1/2
✓ Branch 0 taken 1343285 times.
✗ Branch 1 not taken.
1343285 combobuf[i] = temp_combo;
18314 1343285 }
18315 1343285 }
18316 175 }
18317 else //Call the old function for all old versions
18318 {
18319
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
292 if(ret) return ret; //error, end read
18321 }
18322
18323
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 1 times.
467 if (should_skip)
18324 1 return 0;
18325
18326
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 166 times.
466 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18327 {
18328 166 combobuf[0].walk = 0xF0;
18329 166 combobuf[0].type = 0;
18330 166 combobuf[0].flag = 0;
18331 166 }
18332
18333
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 setup_combo_animations();
18334
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 setup_combo_animations2();
18335 466 return 0;
18336 467 }
18337
18338 384 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18339 {
18340 //these are here to bypass compiler warnings about unused arguments
18341 384 Header=Header;
18342 384 version=version;
18343 384 build=build;
18344
18345 int32_t dummy;
18346 384 word sversion=0, c_sversion;
18347
18348 //section version info
18349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_igetw(&sversion,f))
18350 {
18351 return qe_invalid;
18352 }
18353
18354 384 FFCore.quest_format[vComboAliases] = sversion;
18355
18356
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetw(&c_sversion,f))
18357 {
18358 return qe_invalid;
18359 }
18360
18361 //section size
18362
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&dummy,f))
18363 {
18364 return qe_invalid;
18365 }
18366
18367 384 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18368
18369
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 204 times.
384 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18370 {
18371 204 max_num_combo_aliases = MAX250COMBOALIASES;
18372 204 }
18373
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18374 {
18375 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18376 }
18377
18378
2/2
✓ Branch 0 taken 1892352 times.
✓ Branch 1 taken 384 times.
1892736 for(int32_t j=0; j<max_num_combo_aliases; j++)
18379 {
18380 byte width,height,mask,tempcset;
18381 int32_t count;
18382 word tempword;
18383 byte tempbyte;
18384
18385
1/2
✓ Branch 0 taken 1892352 times.
✗ Branch 1 not taken.
1892352 if(!p_igetw(&tempword,f))
18386 {
18387 return qe_invalid;
18388 }
18389
18390 1892352 combo_aliases[j].combo = tempword;
18391
18392
1/2
✓ Branch 0 taken 1892352 times.
✗ Branch 1 not taken.
1892352 if(!p_getc(&tempbyte,f))
18393 {
18394 return qe_invalid;
18395 }
18396
18397 1892352 combo_aliases[j].cset = tempbyte;
18398
18399
1/2
✓ Branch 0 taken 1892352 times.
✗ Branch 1 not taken.
1892352 if(!p_getc(&width,f))
18400 {
18401 return qe_invalid;
18402 }
18403
18404
1/2
✓ Branch 0 taken 1892352 times.
✗ Branch 1 not taken.
1892352 if(!p_getc(&height,f))
18405 {
18406 return qe_invalid;
18407 }
18408
18409
1/2
✓ Branch 0 taken 1892352 times.
✗ Branch 1 not taken.
1892352 if(!p_getc(&mask,f))
18410 {
18411 return qe_invalid;
18412 }
18413
18414 1892352 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18415
18416 1892352 combo_aliases[j].width = width;
18417 1892352 combo_aliases[j].height = height;
18418 1892352 combo_aliases[j].layermask = mask;
18419 1892352 combo_aliases[j].combos.clear();
18420 1892352 combo_aliases[j].csets.clear();
18421
18422
2/2
✓ Branch 0 taken 1942420 times.
✓ Branch 1 taken 1892352 times.
3834772 for(int32_t k=0; k<count; k++)
18423 {
18424
1/2
✓ Branch 0 taken 1942420 times.
✗ Branch 1 not taken.
1942420 if(!p_igetw(&tempword,f))
18425 {
18426 return qe_invalid;
18427 }
18428
18429 1942420 combo_aliases[j].combos[k] = tempword;
18430 1942420 }
18431
18432
2/2
✓ Branch 0 taken 1942420 times.
✓ Branch 1 taken 1892352 times.
3834772 for(int32_t k=0; k<count; k++)
18433 {
18434
1/2
✓ Branch 0 taken 1942420 times.
✗ Branch 1 not taken.
1942420 if(!p_getc(&tempcset,f))
18435 {
18436 return qe_invalid;
18437 }
18438
18439 1942420 combo_aliases[j].csets[k] = tempcset;
18440 1942420 }
18441 1892352 }
18442
18443 //Combo pools!
18444 384 word num_combo_pools = 0;
18445
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 175 times.
384 if(sversion >= 4)
18446 {
18447
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if(!p_igetw(&num_combo_pools,f))
18448 {
18449 return qe_invalid;
18450 }
18451 175 }
18452
18453
2/2
✓ Branch 0 taken 3145728 times.
✓ Branch 1 taken 384 times.
3146112 for(combo_pool& pool : combo_pools)
18454 {
18455 3145728 pool.clear();
18456 }
18457
18458 384 combo_pool temp_cpool;
18459
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 384 times.
822 for(word cp = 0; cp < num_combo_pools; ++cp)
18460 {
18461 438 int32_t num_combos_in_pool = 0;
18462
2/4
✓ Branch 0 taken 438 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 438 times.
✗ Branch 3 not taken.
438 if(!p_igetl(&num_combos_in_pool,f))
18463 {
18464 return qe_invalid;
18465 }
18466
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 96 times.
438 if(num_combos_in_pool < 1) continue; //nothing to read
18467
18468
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 temp_cpool.clear();
18469
18470 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18471
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 1550 times.
1892 for(auto q = 0; q < num_combos_in_pool; ++q)
18472 {
18473
2/4
✓ Branch 0 taken 1550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1550 times.
✗ Branch 3 not taken.
1550 if(!p_igetl(&cp_cid,f))
18474 {
18475 return qe_invalid;
18476 }
18477
2/4
✓ Branch 0 taken 1550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1550 times.
✗ Branch 3 not taken.
1550 if(!p_getc(&cp_cs,f))
18478 {
18479 return qe_invalid;
18480 }
18481
2/4
✓ Branch 0 taken 1550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1550 times.
✗ Branch 3 not taken.
1550 if(!p_igetw(&cp_quant,f))
18482 {
18483 return qe_invalid;
18484 }
18485
1/2
✓ Branch 0 taken 1550 times.
✗ Branch 1 not taken.
1550 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18486 1550 }
18487
18488
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 combo_pools[cp] = temp_cpool;
18489 342 }
18490
18491 //Autocombos!
18492 384 word num_combo_autos = 0;
18493
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 221 times.
384 if (sversion >= 5)
18494 {
18495
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if (!p_igetw(&num_combo_autos, f))
18496 {
18497 return qe_invalid;
18498 }
18499 163 }
18500
18501
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 3145728 times.
3146112 for (combo_auto& cauto : combo_autos)
18502 {
18503
1/2
✓ Branch 0 taken 3145728 times.
✗ Branch 1 not taken.
3145728 cauto.clear(true);
18504 }
18505
18506
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 combo_auto temp_cauto;
18507
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 384 times.
459 for (word ca = 0; ca < num_combo_autos; ++ca)
18508 {
18509 byte type;
18510 int32_t display_cid, erase_cid;
18511 byte flags, arg;
18512
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_getc(&type, f))
18513 {
18514 return qe_invalid;
18515 }
18516
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_igetl(&display_cid, f))
18517 {
18518 return qe_invalid;
18519 }
18520
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_igetl(&erase_cid, f))
18521 {
18522 return qe_invalid;
18523 }
18524
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_getc(&flags, f))
18525 {
18526 return qe_invalid;
18527 }
18528
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_getc(&arg, f))
18529 {
18530 return qe_invalid;
18531 }
18532 75 int32_t num_combos_in_cauto = 0;
18533
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if (!p_igetl(&num_combos_in_cauto, f))
18534 {
18535 return qe_invalid;
18536 }
18537
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if (num_combos_in_cauto < 1) continue; //nothing to read
18538
18539
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.clear();
18540
18541
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setType(type);
18542
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setDisplay(display_cid);
18543
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setEraseCombo(erase_cid);
18544
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setFlags(flags);
18545
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 temp_cauto.setArg(arg);
18546
18547 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18548
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 930 times.
1005 for (auto q = 0; q < num_combos_in_cauto; ++q)
18549 {
18550
2/4
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
930 if (!p_getc(&ca_ctype, f))
18551 {
18552 return qe_invalid;
18553 }
18554
2/4
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
930 if (!p_igetl(&ca_cid, f))
18555 {
18556 return qe_invalid;
18557 }
18558
1/2
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
930 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18559 930 }
18560
18561
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 combo_autos[ca] = temp_cauto;
18562 75 }
18563
18564 384 return 0;
18565 384 }
18566
18567 779 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18568 {
18569
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 24 times.
779 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18570
18571 //these are here to bypass compiler warnings about unused arguments
18572 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18573 //Capitalized cause it'll save you a headache. -Deedee
18574 779 start_cset=start_cset;
18575 779 max_csets=max_csets;
18576 779 word s_version=0;
18577
18578 miscQdata temp_misc;
18579 779 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18580
18581 byte temp_colordata[48];
18582 char temp_palname[PALNAMESIZE+1];
18583
18584 int32_t dummy;
18585 word palcycles;
18586
18587
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 755 times.
779 if(version > 0x192)
18588 {
18589 //section version info
18590
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(!p_igetw(&s_version,f))
18591 {
18592 return qe_invalid;
18593 }
18594
18595 755 FFCore.quest_format[vCSets] = s_version;
18596
18597
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(!p_igetw(&dummy,f))
18598 {
18599 return qe_invalid;
18600 }
18601
18602 //section size
18603
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(!p_igetl(&dummy,f))
18604 {
18605 return qe_invalid;
18606 }
18607 755 }
18608
2/2
✓ Branch 0 taken 599 times.
✓ Branch 1 taken 180 times.
779 if (s_version < 5)
18609 {
18610
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 581 times.
✓ Branch 2 taken 575 times.
✓ Branch 3 taken 6 times.
599 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18611
18612 //finally... section data
18613 599 int32_t q = 0;
18614 599 int32_t p = -15;
18615
2/2
✓ Branch 0 taken 143760 times.
✓ Branch 1 taken 599 times.
144359 for(int32_t i=0; i<oldpdTOTAL; ++i)
18616 {
18617 143760 memset(temp_colordata, 0, 48);
18618
18619
1/2
✓ Branch 0 taken 143760 times.
✗ Branch 1 not taken.
143760 if(!pfread(temp_colordata,48,f))
18620 {
18621 return qe_invalid;
18622 }
18623
18624
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 143520 times.
143760 if (should_skip)
18625 240 continue;
18626
18627 143520 memcpy(&colordata[q*48], temp_colordata, 48);
18628
18629 143520 ++q;
18630
8/8
✓ Branch 0 taken 133952 times.
✓ Branch 1 taken 9568 times.
✓ Branch 2 taken 10166 times.
✓ Branch 3 taken 123786 times.
✓ Branch 4 taken 1196 times.
✓ Branch 5 taken 8970 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1160 times.
143520 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18631 {
18632
1/2
✓ Branch 0 taken 10130 times.
✗ Branch 1 not taken.
10130 if (s_version < 5) //Bumping up the size of level palettes
18633 {
18634 10130 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18635 10130 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18636 10130 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18637 10130 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18638 10130 q+=4;
18639 10130 }
18640 else
18641 {
18642 for(int m = 0; m < 4; ++m)
18643 {
18644 memset(temp_colordata, 0, 48);
18645 if(!pfread(temp_colordata,48,f))
18646 {
18647 return qe_invalid;
18648 }
18649 memcpy(&colordata[q*48], temp_colordata, 48);
18650 ++q;
18651 }
18652 }
18653 10130 }
18654 143520 ++p;
18655 143520 }
18656
18657
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 581 times.
599 if(RealOldVerion)
18658 {
18659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18660 {
18661 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18662 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18663 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18664 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18665 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18666 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18667 18 }
18668 18 }
18669 else
18670 {
18671 581 memset(temp_colordata, 0, 48);
18672
18673
2/2
✓ Branch 0 taken 1820273 times.
✓ Branch 1 taken 581 times.
1820854 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18674 {
18675
1/2
✓ Branch 0 taken 1820273 times.
✗ Branch 1 not taken.
1820273 if(!pfread(temp_colordata,48,f))
18676 {
18677 return qe_invalid;
18678 }
18679
18680
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 1817140 times.
1820273 if (should_skip)
18681 3133 continue;
18682
18683 1817140 memcpy(&colordata[q*48], temp_colordata, 48);
18684
18685 1817140 ++q;
18686
7/8
✓ Branch 0 taken 1817140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139780 times.
✓ Branch 3 taken 1677360 times.
✓ Branch 4 taken 1160 times.
✓ Branch 5 taken 138620 times.
✓ Branch 6 taken 1032 times.
✓ Branch 7 taken 128 times.
1817140 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18687 {
18688
1/2
✓ Branch 0 taken 139652 times.
✗ Branch 1 not taken.
139652 if (s_version < 5) //Bumping up the size of level palettes
18689 {
18690 139652 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18691 139652 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18692 139652 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18693 139652 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18694 139652 q+=4;
18695 139652 }
18696 else
18697 {
18698 for(int m = 0; m < 4; ++m)
18699 {
18700 memset(temp_colordata, 0, 48);
18701 if(!pfread(temp_colordata,48,f))
18702 {
18703 return qe_invalid;
18704 }
18705 memcpy(&colordata[q*48], temp_colordata, 48);
18706 ++q;
18707 }
18708 }
18709 139652 }
18710 1817140 ++p;
18711 1817140 }
18712
18713
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 516 times.
581 if(s_version < 4)
18714 {
18715
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
18716 {
18717 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18718 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18719 64 }
18720 65 }
18721 else
18722 {
18723
2/2
✓ Branch 0 taken 1717248 times.
✓ Branch 1 taken 516 times.
1717764 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18724 {
18725
1/2
✓ Branch 0 taken 1717248 times.
✗ Branch 1 not taken.
1717248 if(!pfread(temp_colordata,48,f))
18726 {
18727 return qe_invalid;
18728 }
18729
18730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1717248 times.
1717248 if (should_skip)
18731 continue;
18732
18733 1717248 memcpy(&colordata[q*48], temp_colordata, 48);
18734 1717248 ++q;
18735
5/6
✓ Branch 0 taken 1717248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132096 times.
✓ Branch 3 taken 1585152 times.
✓ Branch 4 taken 1032 times.
✓ Branch 5 taken 131064 times.
1717248 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18736 {
18737
1/2
✓ Branch 0 taken 131064 times.
✗ Branch 1 not taken.
131064 if (s_version < 5) //Bumping up the size of level palettes
18738 {
18739 131064 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18740 131064 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18741 131064 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18742 131064 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18743 131064 q+=4;
18744 131064 }
18745 else
18746 {
18747 for(int m = 0; m < 4; ++m)
18748 {
18749 memset(temp_colordata, 0, 48);
18750 if(!pfread(temp_colordata,48,f))
18751 {
18752 return qe_invalid;
18753 }
18754 memcpy(&colordata[q*48], temp_colordata, 48);
18755 ++q;
18756 }
18757 }
18758 131064 }
18759 1717248 ++p;
18760 1717248 }
18761
18762 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18763 }
18764 }
18765 599 }
18766 else
18767 {
18768
2/2
✓ Branch 0 taken 1574820 times.
✓ Branch 1 taken 180 times.
1575000 for(int32_t i=0; i<pdTOTAL255; ++i)
18769 {
18770 1574820 memset(temp_colordata, 0, 48);
18771
18772
1/2
✓ Branch 0 taken 1574820 times.
✗ Branch 1 not taken.
1574820 if(!pfread(temp_colordata,48,f))
18773 {
18774 return qe_invalid;
18775 }
18776
18777 1574820 memcpy(&colordata[i*48], temp_colordata, 48);
18778 1574820 }
18779 }
18780
18781
4/4
✓ Branch 0 taken 778 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 643 times.
779 if (!should_skip && s_version < 6)
18782 {
18783
2/2
✓ Branch 0 taken 270029136 times.
✓ Branch 1 taken 643 times.
270029779 for (int i = 0; i < psTOTAL255; i++)
18784 {
18785 270029136 colordata[i] = _rgb_scale_6[colordata[i]];
18786 270029136 }
18787 643 }
18788
18789
5/6
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 755 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
779 if((version < 0x192)||((version == 0x192)&&(build<76)))
18790 {
18791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18792 18 init_palnames();
18793 18 }
18794 else
18795 {
18796 761 int32_t palnamestoread = 0;
18797
18798
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 696 times.
761 if(s_version < 3)
18799 65 palnamestoread = OLDMAXLEVELS;
18800 else
18801 696 palnamestoread = 512;
18802
18803
2/2
✓ Branch 0 taken 372992 times.
✓ Branch 1 taken 761 times.
373753 for(int32_t i=0; i<palnamestoread; ++i)
18804 {
18805
1/2
✓ Branch 0 taken 372992 times.
✗ Branch 1 not taken.
372992 if(!p_getstr(temp_palname,PALNAMESIZE,f))
18806 {
18807 return qe_invalid;
18808 }
18809
18810
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 372736 times.
372992 if (!should_skip)
18811 372736 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18812 372992 }
18813
18814
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 760 times.
761 if (should_skip)
18815 1 return 0;
18816
18817
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 760 times.
17144 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18818 {
18819 16384 memset(palnames[i], 0, PALNAMESIZE);
18820 16384 }
18821 }
18822
18823
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 755 times.
778 if(version > 0x192)
18824 {
18825
2/2
✓ Branch 0 taken 193280 times.
✓ Branch 1 taken 755 times.
194035 for(int32_t i=0; i<256; i++)
18826 {
18827
2/2
✓ Branch 0 taken 579840 times.
✓ Branch 1 taken 193280 times.
773120 for(int32_t j=0; j<3; j++)
18828 {
18829 579840 temp_misc.cycles[i][j].first=0;
18830 579840 temp_misc.cycles[i][j].count=0;
18831 579840 temp_misc.cycles[i][j].speed=0;
18832 579840 }
18833 193280 }
18834
18835
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(!p_igetw(&palcycles,f))
18836 {
18837 return qe_invalid;
18838 }
18839
18840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
755 if (palcycles > NUM_PAL_CYCLES)
18841 {
18842 return qe_invalid;
18843 }
18844
18845
2/2
✓ Branch 0 taken 21898 times.
✓ Branch 1 taken 755 times.
22653 for(int32_t i=0; i<palcycles; i++)
18846 {
18847
2/2
✓ Branch 0 taken 65694 times.
✓ Branch 1 taken 21898 times.
87592 for(int32_t j=0; j<3; j++)
18848 {
18849
1/2
✓ Branch 0 taken 65694 times.
✗ Branch 1 not taken.
65694 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18850 {
18851 return qe_invalid;
18852 }
18853 65694 }
18854
18855
2/2
✓ Branch 0 taken 65694 times.
✓ Branch 1 taken 21898 times.
87592 for(int32_t j=0; j<3; j++)
18856 {
18857
1/2
✓ Branch 0 taken 65694 times.
✗ Branch 1 not taken.
65694 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18858 {
18859 return qe_invalid;
18860 }
18861 65694 }
18862
18863
2/2
✓ Branch 0 taken 65694 times.
✓ Branch 1 taken 21898 times.
87592 for(int32_t j=0; j<3; j++)
18864 {
18865
1/2
✓ Branch 0 taken 65694 times.
✗ Branch 1 not taken.
65694 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18866 {
18867 return qe_invalid;
18868 }
18869 65694 }
18870 21898 }
18871
18872 755 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18873 755 }
18874
18875 778 return 0;
18876 779 }
18877
18878 779 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18879 {
18880
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 24 times.
779 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
18881
18882 779 int32_t tiles_used=0;
18883 779 word section_version = 0;
18884 779 int32_t section_size= 0;
18885 779 byte *temp_tile = new byte[tilesize(tf32Bit)];
18886
18887 //Tile Expansion
18888 //if ( version >= 0x254 && build >= 41 )
18889
4/4
✓ Branch 0 taken 599 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 593 times.
779 if (version < 0x254 && build < 41)
18890 {
18891 593 max_tiles = ZC250MAXTILES;
18892 593 }
18893
18894
18895
2/6
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 779 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
779 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18896 {
18897 if(!init_tiles_for_190(true, Header))
18898 {
18899 al_trace("Unable to initialize tiles\n");
18900 }
18901
18902 delete[] temp_tile;
18903 temp_tile=NULL;
18904 return 0;
18905 }
18906 else
18907 {
18908
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 755 times.
779 if(version > 0x192)
18909 {
18910 //section version info
18911
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(!p_igetw(&section_version,f))
18912 {
18913 delete[] temp_tile;
18914 return qe_invalid;
18915 }
18916
18917 755 FFCore.quest_format[vTiles] = section_version;
18918
18919
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(!read_deprecated_section_cversion(f))
18920 {
18921 delete[] temp_tile;
18922 return qe_invalid;
18923 }
18924
18925 //section size
18926
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(!p_igetl(&section_size,f))
18927 {
18928 delete[] temp_tile;
18929 return qe_invalid;
18930 }
18931 755 }
18932
18933 //if ( build < 41 )
18934 //{
18935 // tiles_used = ZC250MAXTILES;
18936 //}
18937
18938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779 times.
779 if(version < 0x174)
18939 {
18940 tiles_used=TILES_PER_PAGE*4;
18941 } //no expanded tile space
18942
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 761 times.
779 else if(version < 0x191)
18943 {
18944 18 tiles_used=OLDMAXTILES;
18945 18 }
18946 else
18947 {
18948 //finally... section data
18949
3/4
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 581 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180 times.
761 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18950 {
18951
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if(!p_igetl(&tiles_used,f))
18952 {
18953 delete[] temp_tile;
18954 return qe_invalid;
18955 }
18956 180 }
18957 else
18958 {
18959
1/2
✓ Branch 0 taken 581 times.
✗ Branch 1 not taken.
581 if(!p_igetw(&tiles_used,f))
18960 {
18961 delete[] temp_tile;
18962 return qe_invalid;
18963 }
18964 }
18965 }
18966
18967
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 tiles_used=zc_min(tiles_used, max_tiles);
18968
18969 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
18970 //if ( version < 0x254 && build < 41 )
18971
3/6
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 599 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
779 if ( version < 0x254 || (version == 0x254 && build < 41) )
18972 //if ( build < 41 )
18973 {
18974
1/2
✓ Branch 0 taken 599 times.
✗ Branch 1 not taken.
599 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
18975 599 }
18976 else //2.55
18977 {
18978
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
18979 }
18980
18981 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
18982
18983
18984
2/2
✓ Branch 0 taken 17971219 times.
✓ Branch 1 taken 779 times.
17971998 for(int32_t i=0; i<tiles_used; ++i)
18985 {
18986 17971219 byte format=tf4Bit;
18987 17971219 memset(temp_tile, 0, tilesize(tf32Bit));
18988
18989
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 14985763 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17971219 if((version>0x211)||((version==0x211)&&(build>4)))
18990 {
18991
1/2
✓ Branch 0 taken 14985763 times.
✗ Branch 1 not taken.
14985763 if(!p_getc(&format,f))
18992 {
18993 delete[] temp_tile;
18994 return qe_invalid;
18995 }
18996 14985763 }
18997
4/4
✓ Branch 0 taken 6852064 times.
✓ Branch 1 taken 11119155 times.
✓ Branch 2 taken 3138277 times.
✓ Branch 3 taken 3713787 times.
17971219 if(section_version > 2 && !format)
18998 {
18999 3713787 reset_tile(buf,start_tile+i,tf4Bit);
19000 3713787 continue;
19001 }
19002
19003
2/2
✓ Branch 0 taken 13783200 times.
✓ Branch 1 taken 474232 times.
14257432 int size = format == tf4Bit ? 128 : tilesize(format);
19004
1/2
✓ Branch 0 taken 14257432 times.
✗ Branch 1 not taken.
14257432 if(!pfread(temp_tile,size,f))
19005 {
19006 delete[] temp_tile;
19007 return qe_invalid;
19008 }
19009
19010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14257432 times.
14257432 if (should_skip)
19011 continue;
19012
19013 14257432 buf[start_tile+i].format=format;
19014
19015
2/2
✓ Branch 0 taken 14053547 times.
✓ Branch 1 taken 203885 times.
14257432 if(buf[start_tile+i].data)
19016 {
19017 14053547 free(buf[start_tile+i].data);
19018 14053547 buf[start_tile+i].data=NULL;
19019 14053547 }
19020
19021 14257432 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19022
19023
2/2
✓ Branch 0 taken 13783200 times.
✓ Branch 1 taken 474232 times.
14257432 if (format == tf4Bit)
19024 {
19025 byte temp[256];
19026 13783200 byte *si = temp_tile + 128;
19027 13783200 byte *di = temp + 256;
19028
19029
2/2
✓ Branch 0 taken 1764249600 times.
✓ Branch 1 taken 13783200 times.
1778032800 for(int i=127; i>=0; --i)
19030 {
19031 1764249600 (*(--di)) = (*(--si)) >> 4;
19032 1764249600 (*(--di)) = (*si) & 15;
19033 1764249600 }
19034
19035 13783200 memcpy(buf[start_tile+i].data,temp,256);
19036 13783200 }
19037 else
19038 {
19039 474232 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19040 }
19041 14257432 }
19042 }
19043
19044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779 times.
779 if (should_skip)
19045 return 0;
19046
19047
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 599 times.
779 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19048 {
19049
2/2
✓ Branch 0 taken 89239020 times.
✓ Branch 1 taken 599 times.
89239619 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19050 {
19051
19052 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19053 89239020 reset_tile(buf,q,tf4Bit);
19054
19055
19056 /*
19057
19058 byte tempbyte;
19059 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19060 {
19061 tempbyte=buf[ZC250MAXTILES-1].data[i];
19062 buf[q].data[i] = tempbyte;
19063 }
19064 //int32_t temp = tempbyte=buf[130].data[i];
19065 //buf[q].data = buf[ZC250MAXTILES-1].data;
19066 */
19067 //reset_tile(buf,q,tf4Bit);
19068 89239020 }
19069
19070 599 }
19071
19072
4/6
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 599 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 180 times.
779 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19073 {
19074
2/2
✓ Branch 0 taken 29594921 times.
✓ Branch 1 taken 599 times.
29595520 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19075 {
19076 29594921 reset_tile(buf,i,tf4Bit);
19077 29594921 }
19078 599 }
19079 else
19080 {
19081
2/2
✓ Branch 0 taken 31184220 times.
✓ Branch 1 taken 180 times.
31184400 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19082 {
19083 31184220 reset_tile(buf,i,tf4Bit);
19084 31184220 }
19085 }
19086
19087
5/6
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 755 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
779 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19088 {
19089
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
19090 {
19091 byte tempbyte;
19092 6 int32_t floattile=wpnsbuf[iwSwim].tile;
19093
19094
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19095 {
19096 1536 tempbyte=buf[23].data[i];
19097 1536 buf[23].data[i]=buf[24].data[i];
19098 1536 buf[24].data[i]=buf[25].data[i];
19099 1536 buf[25].data[i]=buf[26].data[i];
19100 1536 buf[26].data[i]=tempbyte;
19101 1536 }
19102 //swim tiles are out of order, too, but nobody cared? -Z
19103
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19104 {
19105 1536 tempbyte=buf[floattile+11].data[i];
19106 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19107 1536 buf[floattile+12].data[i]=tempbyte;
19108 1536 }
19109 6 }
19110 24 }
19111
19112
3/6
✓ Branch 0 taken 696 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 696 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
779 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19113 {
19114
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
19115 {
19116 byte tempbyte;
19117
19118
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19119 {
19120 5632 tempbyte=buf[130].data[i];
19121 5632 buf[130].data[i]=buf[132].data[i];
19122 5632 buf[132].data[i]=tempbyte;
19123
19124 5632 tempbyte=buf[131].data[i];
19125 5632 buf[131].data[i]=buf[133].data[i];
19126 5632 buf[133].data[i]=tempbyte;
19127 5632 }
19128 22 }
19129 83 }
19130
19131 779 al_trace("Registering blank tiles\n");
19132 779 register_blank_tiles();
19133
19134 //memset(temp_tile, 0, tilesize(tf32Bit));
19135
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 delete[] temp_tile;
19136 779 temp_tile=NULL;
19137 779 return 0;
19138 779 }
19139
19140 466 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19141 {
19142
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
466 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19143
19144 static byte fake_midi_flags[32];
19145
19146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19147 int32_t dummy;
19148 word dummy2;
19149 // zcmidi_ temp_midi;
19150 int32_t tunes_to_read;
19151 466 int32_t tune_count=0;
19152 466 word section_version=0;
19153 466 zctune temp;
19154
19155
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 443 times.
466 if(Header->zelda_version < 0x193)
19156 {
19157 // mf=Header->data_flags+ZQ_MIDIS2;
19158
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19159 {
19160 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19161 22 }
19162 else
19163 {
19164 1 tunes_to_read=MAXCUSTOMTUNES;
19165 }
19166 23 }
19167 else
19168 {
19169 //section version info
19170
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&section_version,f))
19171 {
19172 return qe_invalid;
19173 }
19174
19175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if (!should_skip)
19176 443 FFCore.quest_format[vMIDIs] = section_version;
19177
19178
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&dummy2,f))
19179 {
19180 return qe_invalid;
19181 }
19182
19183 //section size
19184
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetl(&dummy,f))
19185 {
19186 return qe_invalid;
19187 }
19188
19189 //finally... section data
19190
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!pfread(midi_flags,sizeof(midi_flags),f))
19191 {
19192 return qe_invalid;
19193 }
19194
19195 443 tunes_to_read=MAXCUSTOMTUNES;
19196 }
19197
19198
2/2
✓ Branch 0 taken 117432 times.
✓ Branch 1 taken 466 times.
117898 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19199 {
19200
2/2
✓ Branch 0 taken 10202 times.
✓ Branch 1 taken 107230 times.
117432 if(get_bit(mf, i))
19201 {
19202 10202 ++tune_count;
19203 10202 }
19204 117432 }
19205
19206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if (!should_skip)
19207 466 reset_tunes(tunes); //reset_midis(midis);
19208
19209
2/2
✓ Branch 0 taken 112592 times.
✓ Branch 1 taken 466 times.
113058 for(int32_t i=0; i<tunes_to_read; i++)
19210 {
19211 112592 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19212
19213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112592 times.
112592 if (!should_skip)
19214 112592 tunes[i].reset(); // reset_midi(midis+i);
19215
19216
2/2
✓ Branch 0 taken 102390 times.
✓ Branch 1 taken 10202 times.
112592 if(get_bit(mf,i))
19217 {
19218
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7539 times.
10202 if(section_version < 4)
19219 {
19220
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
19221 {
19222 return qe_invalid;
19223 }
19224 2663 }
19225 else
19226 {
19227
1/2
✓ Branch 0 taken 7539 times.
✗ Branch 1 not taken.
7539 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19228 {
19229 return qe_invalid;
19230 }
19231 }
19232
19233
1/2
✓ Branch 0 taken 10202 times.
✗ Branch 1 not taken.
10202 if(!p_igetl(&temp.start,f))
19234 {
19235 return qe_invalid;
19236 }
19237
19238
1/2
✓ Branch 0 taken 10202 times.
✗ Branch 1 not taken.
10202 if(!p_igetl(&temp.loop_start,f))
19239 {
19240 return qe_invalid;
19241 }
19242
19243
1/2
✓ Branch 0 taken 10202 times.
✗ Branch 1 not taken.
10202 if(!p_igetl(&temp.loop_end,f))
19244 {
19245 return qe_invalid;
19246 }
19247
19248
1/2
✓ Branch 0 taken 10202 times.
✗ Branch 1 not taken.
10202 if(!p_igetw(&temp.loop,f))
19249 {
19250 return qe_invalid;
19251 }
19252
19253
1/2
✓ Branch 0 taken 10202 times.
✗ Branch 1 not taken.
10202 if(!p_igetw(&temp.volume,f))
19254 {
19255 return qe_invalid;
19256 }
19257
19258
2/2
✓ Branch 0 taken 9953 times.
✓ Branch 1 taken 249 times.
10202 if(Header->zelda_version < 0x193)
19259 {
19260
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19261 {
19262 return qe_invalid;
19263 }
19264 249 }
19265
19266
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7539 times.
10202 if(section_version >= 3)
19267 {
19268
1/2
✓ Branch 0 taken 7539 times.
✗ Branch 1 not taken.
7539 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19269 {
19270 return qe_invalid;
19271 }
19272 7539 }
19273
19274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10202 times.
10202 if (!should_skip)
19275 10202 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19276
19277
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7539 times.
10202 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19278 {
19279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19280 {
19281 if (read_midi(f)==NULL)
19282 {
19283 return qe_invalid;
19284 }
19285
19286 continue;
19287 }
19288
19289 // old format - a midi is a midi
19290
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19291 {
19292 return qe_invalid;
19293 }
19294 2663 }
19295 else
19296 {
19297 byte format;
19298
1/2
✓ Branch 0 taken 7539 times.
✗ Branch 1 not taken.
7539 if(!pfread(&format,sizeof(format),f))
19299 {
19300 return qe_invalid;
19301 }
19302
19303 // MIDI is the only format saved here.
19304 // Never did more than MIDI for a zctune, and no plans to now.
19305
1/2
✓ Branch 0 taken 7539 times.
✗ Branch 1 not taken.
7539 if (format != MFORMAT_MIDI)
19306 {
19307 return qe_invalid;
19308 }
19309
19310 7539 tunes[i].data = read_midi(f);
19311
1/2
✓ Branch 0 taken 7539 times.
✗ Branch 1 not taken.
7539 if (!tunes[i].data)
19312 {
19313 return qe_invalid;
19314 }
19315 }
19316 10202 }
19317 112592 }
19318
19319 466 return 0;
19320 466 }
19321
19322 466 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19323 {
19324
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
466 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19325
19326 int32_t dummy;
19327 ZCHEATS tempzcheats;
19328 466 char temp_use_cheats=1;
19329 466 memset(&tempzcheats, 0, sizeof(tempzcheats));
19330 466 word s_version = 0;
19331
19332
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 443 times.
466 if(Header->zelda_version > 0x192)
19333 {
19334 //section version info
19335
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&s_version,f))
19336 {
19337 return qe_invalid;
19338 }
19339
19340 443 FFCore.quest_format[vCheats] = s_version;
19341
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetw(&dummy,f))
19342 {
19343 return qe_invalid;
19344 }
19345
19346 //section size
19347
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(!p_igetl(&dummy,f))
19348 {
19349 return qe_invalid;
19350 }
19351
19352 //finally... section data
19353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(!p_getc(&temp_use_cheats,f))
19354 {
19355 return qe_invalid;
19356 }
19357 443 }
19358
19359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if(Header->data_flags[ZQ_CHEATS2])
19360 {
19361
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 if(!p_igetl(&tempzcheats.flags,f))
19362 {
19363 return qe_invalid;
19364 }
19365
19366
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19367 {
19368 return qe_invalid;
19369 }
19370 466 }
19371
19372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if (should_skip)
19373 return 0;
19374
19375 466 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19376 466 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19377
19378 466 return 0;
19379 466 }
19380
19381 303 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, zinitdata& temp_zinit)
19382 {
19383
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 280 times.
303 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19384
19385 byte padding, tempbyte;
19386
19387 // Legacy item properties (now integrated into itemdata)
19388 byte sword_hearts[4];
19389 byte beam_hearts[4];
19390 303 byte beam_percent=0;
19391 word beam_power[4];
19392 303 byte hookshot_length=99;
19393 303 byte hookshot_links=100;
19394 303 byte longshot_length=99;
19395 303 byte longshot_links=100;
19396 303 byte moving_fairy_hearts=3;
19397 303 byte moving_fairy_heart_percent=0;
19398 303 byte stationary_fairy_hearts=3;
19399 303 byte stationary_fairy_heart_percent=0;
19400 303 byte moving_fairy_magic=0;
19401 303 byte moving_fairy_magic_percent=0;
19402 303 byte stationary_fairy_magic=0;
19403 303 byte stationary_fairy_magic_percent=0;
19404 303 byte blue_potion_hearts=100;
19405 303 byte blue_potion_heart_percent=1;
19406 303 byte red_potion_hearts=100;
19407 303 byte red_potion_heart_percent=1;
19408 303 byte blue_potion_magic=100;
19409 303 byte blue_potion_magic_percent=1;
19410 303 byte red_potion_magic=100;
19411 303 byte red_potion_magic_percent=1;
19412
19413 303 byte bomb_ratio = 4;
19414
19415 303 subscr_mode = 0;
19416
19417 /* HIGHLY UNORTHODOX UPDATING THING, by L
19418 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19419 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19420 * changing from 13 to 14.
19421 */
19422
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 82 times.
303 if(s_version < 14)
19423 82 fixpolsvoice=true;
19424
19425 /* End highly unorthodox updating thing */
19426
19427
4/4
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 113 times.
303 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19428 113 temp_zinit.jump_hero_layer_threshold=0;
19429
19430
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 221 times.
303 if(s_version >= 10)
19431 {
19432 char temp;
19433
19434 //new-style items
19435
2/2
✓ Branch 0 taken 56576 times.
✓ Branch 1 taken 221 times.
56797 for(int32_t j=0; j<256; j++)
19436 {
19437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56576 times.
56576 if(!p_getc(&temp,f))
19438 return qe_invalid;
19439
19440 56576 temp_zinit.set_item(j, temp != 0);
19441 56576 }
19442 221 }
19443
19444
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
303 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19445 {
19446 char temp;
19447
19448 //finally... section data
19449
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
290 if((Header->zelda_version > 0x192)||
19450 //new only
19451
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19452 {
19453 //OLD-style items... sigh
19454
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 60 times.
281 if(s_version < 10)
19455 {
19456
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19457 {
19458 return qe_invalid;
19459 }
19460
19461 60 temp_zinit.set_item(iRaft, temp != 0);
19462
19463
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19464 {
19465 return qe_invalid;
19466 }
19467
19468 60 temp_zinit.set_item(iLadder, temp != 0);
19469
19470
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19471 {
19472 return qe_invalid;
19473 }
19474
19475 60 temp_zinit.set_item(iBook, temp != 0);
19476
19477
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19478 {
19479 return qe_invalid;
19480 }
19481
19482 60 temp_zinit.set_item(iMKey, temp != 0);
19483
19484
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19485 {
19486 return qe_invalid;
19487 }
19488
19489 60 temp_zinit.set_item(iFlippers, temp != 0);
19490
19491
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19492 {
19493 return qe_invalid;
19494 }
19495
19496 60 temp_zinit.set_item(iBoots, temp != 0);
19497 60 }
19498 281 }
19499
19500
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 64 times.
285 if(s_version < 10)
19501 {
19502 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19503
19504
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
19505 {
19506 return qe_invalid;
19507 }
19508
19509
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
19510 {
19511 return qe_invalid;
19512 }
19513
19514
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
19515 {
19516 return qe_invalid;
19517 }
19518
19519
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
19520 {
19521 return qe_invalid;
19522 }
19523
19524
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
19525 {
19526 return qe_invalid;
19527 }
19528
19529
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
19530 {
19531 return qe_invalid;
19532 }
19533
19534
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
19535 {
19536 return qe_invalid;
19537 }
19538
19539 //old only
19540
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19541 {
19542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
19543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19544
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19549 4 }
19550
19551 //rings start at level 2... wtf
19552 //account for this -DD
19553 64 tempring <<= 1;
19554 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19555 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19556 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19557 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19558 //bracelet ALSO starts at level 2 :-( -DD
19559 64 tempbracelet<<=1;
19560 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19561 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19562 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19563
19564 //new only
19565
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
19566 {
19567
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19568 {
19569
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19570 {
19571 return qe_invalid;
19572 }
19573 32 }
19574 1 }
19575
19576 char tempcandle, tempboomerang, temparrow, tempwhistle;
19577
19578
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
19579 {
19580 return qe_invalid;
19581 }
19582
19583
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
19584 {
19585 return qe_invalid;
19586 }
19587
19588
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
19589 {
19590 return qe_invalid;
19591 }
19592
19593
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
19594 {
19595 return qe_invalid;
19596 }
19597
19598 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19599
19600
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
19601 {
19602 return qe_invalid;
19603 }
19604
19605 //old only
19606
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19607 {
19608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19612 4 }
19613
19614 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19615 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19616 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19617 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19618 //What about the potion...?
19619
19620 64 }
19621
19622
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 268 times.
285 if(s_version < 29)
19623 {
19624 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19625 //to jab out my eye...
19626
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if(!p_getc(&padding,f))
19627 return qe_invalid;
19628 268 temp_zinit.counter[crBOMBS] = padding;
19629
19630
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if(!p_getc(&padding,f))
19631 return qe_invalid;
19632 268 temp_zinit.counter[crSBOMBS] = padding;
19633 268 }
19634
19635 //Back to more OLD item code
19636
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 64 times.
285 if(s_version < 10)
19637 {
19638
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
19639 //new only
19640
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19641 {
19642
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19643 {
19644 return qe_invalid;
19645 }
19646
19647 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19648
19649
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19650 {
19651 return qe_invalid;
19652 }
19653
19654 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19655
19656
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19657 {
19658 return qe_invalid;
19659 }
19660
19661 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19662
19663
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19664 {
19665 return qe_invalid;
19666 }
19667
19668 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19669
19670
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19671 {
19672 return qe_invalid;
19673 }
19674
19675 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19676
19677
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19678 {
19679 return qe_invalid;
19680 }
19681
19682 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19683
19684
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19685 {
19686 return qe_invalid;
19687 }
19688
19689 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19690
19691
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19692 {
19693 return qe_invalid;
19694 }
19695
19696 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19697
19698
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19699 {
19700 return qe_invalid;
19701 }
19702
19703 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19704
19705
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19706 {
19707 return qe_invalid;
19708 }
19709
19710
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
19711 {
19712
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19713 {
19714
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19715 {
19716 return qe_invalid;
19717 }
19718 32 }
19719 1 }
19720 60 }
19721 64 }
19722
19723 //old only
19724
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
285 if((Header->zelda_version == 0x192)&&(Header->build<174))
19725 {
19726 byte equipment, tmpitm; //bit flags
19727
19728
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
19729 {
19730 return qe_invalid;
19731 }
19732
19733 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
19734 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
19735 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
19736 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
19737 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
19738 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
19739
19740
19741
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
19742 {
19743 return qe_invalid;
19744 }
19745
19746 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
19747 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
19748 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
19749 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
19750 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
19751 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
19752 4 }
19753
19754
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(!p_getc(&tempbyte,f))
19755 return qe_invalid;
19756 285 temp_zinit.mcounter[crLIFE] = tempbyte;
19757
19758
19759
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 221 times.
285 if(s_version < 14)
19760 {
19761 byte temphp;
19762
19763
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19764 {
19765 return qe_invalid;
19766 }
19767
19768 64 temp_zinit.counter[crLIFE]=temphp;
19769
19770
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19771 {
19772 return qe_invalid;
19773 }
19774
19775 64 temp_zinit.cont_heart=temphp;
19776 64 }
19777 else
19778 {
19779
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
19780 {
19781 return qe_invalid;
19782 }
19783
19784
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.cont_heart,f))
19785 {
19786 return qe_invalid;
19787 }
19788 }
19789
19790
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(!p_getc(&temp_zinit.hcp,f))
19791 {
19792 return qe_invalid;
19793 }
19794
19795
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 221 times.
285 if(s_version >= 14)
19796 {
19797
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19798 {
19799 return qe_invalid;
19800 }
19801
19802
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(s_version<16) // July 2007
19803 {
19804 if(get_qr(qr_BRANGPICKUP+1))
19805 temp_zinit.hcp_per_hc = 0xFF;
19806
19807 //Dispose of legacy rule
19808 set_qr(qr_BRANGPICKUP+1, 0);
19809 }
19810 221 }
19811
19812
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 268 times.
285 if(s_version < 29)
19813 {
19814
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if(!p_getc(&padding,f))
19815 return qe_invalid;
19816 268 temp_zinit.mcounter[crBOMBS] = padding;
19817 268 }
19818
19819
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(!p_getc(&temp_zinit.counter[crKEYS],f))
19820 {
19821 return qe_invalid;
19822 }
19823
19824
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
19825 {
19826 return qe_invalid;
19827 }
19828
19829
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(!p_getc(&tempbyte,f))
19830 return qe_invalid;
19831
2/2
✓ Branch 0 taken 2280 times.
✓ Branch 1 taken 285 times.
2565 for(int q = 0; q < 8; ++q)
19832 2280 set_bit(temp_zinit.mcguffin, q+1, get_bitl(tempbyte, q));
19833
19834
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 221 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
285 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19835 {
19836
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 221 times.
14365 for(int32_t i=0; i<64; i++)
19837 {
19838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14144 times.
14144 if(!p_getc(&temp_zinit.map[i],f))
19839 {
19840 return qe_invalid;
19841 }
19842 14144 }
19843
19844
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 221 times.
14365 for(int32_t i=0; i<64; i++)
19845 {
19846
1/2
✓ Branch 0 taken 14144 times.
✗ Branch 1 not taken.
14144 if(!p_getc(&temp_zinit.compass[i],f))
19847 {
19848 return qe_invalid;
19849 }
19850 14144 }
19851 221 }
19852 else
19853 {
19854
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 64 times.
2112 for(int32_t i=0; i<32; i++)
19855 {
19856
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if(!p_getc(&temp_zinit.map[i],f))
19857 {
19858 return qe_invalid;
19859 }
19860 2048 }
19861
19862
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 64 times.
2112 for(int32_t i=0; i<32; i++)
19863 {
19864
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if(!p_getc(&temp_zinit.compass[i],f))
19865 {
19866 return qe_invalid;
19867 }
19868 2048 }
19869 }
19870
19871
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
290 if((Header->zelda_version > 0x192)||
19872 //new only
19873
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19874 {
19875
3/6
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 221 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
281 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19876 {
19877
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 221 times.
14365 for(int32_t i=0; i<64; i++)
19878 {
19879
1/2
✓ Branch 0 taken 14144 times.
✗ Branch 1 not taken.
14144 if(!p_getc(&temp_zinit.boss_key[i],f))
19880 {
19881 return qe_invalid;
19882 }
19883 14144 }
19884 221 }
19885 else
19886 {
19887
2/2
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 60 times.
1980 for(int32_t i=0; i<32; i++)
19888 {
19889
1/2
✓ Branch 0 taken 1920 times.
✗ Branch 1 not taken.
1920 if(!p_getc(&temp_zinit.boss_key[i],f))
19890 {
19891 return qe_invalid;
19892 }
19893 1920 }
19894 }
19895 281 }
19896
19897 byte tmpmisc[16];
19898
2/2
✓ Branch 0 taken 4560 times.
✓ Branch 1 taken 285 times.
4845 for(int32_t i=0; i<16; i++)
19899
1/2
✓ Branch 0 taken 4560 times.
✗ Branch 1 not taken.
4560 if(!p_getc(&tmpmisc[i],f))
19900 return qe_invalid;
19901 285 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
19902 285 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
19903 285 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
19904
19905
4/4
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
541 if(s_version < 15) for(int32_t i=0; i<4; i++)
19906
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
19907 64 return qe_invalid;
19908
19909
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(!p_getc(&temp_zinit.last_map,f))
19910 {
19911 return qe_invalid;
19912 }
19913
19914
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(!p_getc(&temp_zinit.last_screen,f))
19915 {
19916 return qe_invalid;
19917 }
19918
19919
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 221 times.
285 if(s_version < 14)
19920 {
19921 byte tempmp;
19922
19923
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19924 {
19925 return qe_invalid;
19926 }
19927
19928 64 temp_zinit.mcounter[crMAGIC]=tempmp;
19929
19930
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19931 {
19932 return qe_invalid;
19933 }
19934
19935 64 temp_zinit.counter[crMAGIC]=tempmp;
19936 64 }
19937 else
19938 {
19939
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
19940 {
19941 return qe_invalid;
19942 }
19943
19944
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
19945 {
19946 return qe_invalid;
19947 }
19948 }
19949
19950
19951
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 221 times.
285 if(s_version < 15)
19952 {
19953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
19954 {
19955 64 temp_zinit.mcounter[crMAGIC]*=32;
19956 64 temp_zinit.counter[crMAGIC]*=32;
19957 64 }
19958
19959
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
19960 {
19961
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
19962 {
19963 return qe_invalid;
19964 }
19965 256 }
19966
19967
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
19968 {
19969 return qe_invalid;
19970 }
19971 64 }
19972 else
19973 {
19974
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_getc(&temp_zinit.bomb_ratio,f))
19975 return qe_invalid;
19976
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(temp_zinit.bomb_ratio < 1)
19977 temp_zinit.bomb_ratio = 1;
19978 221 else bomb_ratio = temp_zinit.bomb_ratio; //jank
19979 }
19980
19981
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 64 times.
285 if(s_version < 15)
19982 {
19983 byte tempbp;
19984
19985
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
19986 {
19987
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
19988 {
19989 return qe_invalid;
19990 }
19991
19992 256 beam_power[i]=tempbp;
19993 256 }
19994
19995
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
19996 {
19997 return qe_invalid;
19998 }
19999
20000
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
20001 {
20002 if(!p_getc(&hookshot_length,f))
20003 {
20004 return qe_invalid;
20005 }
20006
20007 if(!p_getc(&longshot_links,f))
20008 {
20009 return qe_invalid;
20010 }
20011
20012 if(!p_getc(&longshot_length,f))
20013 {
20014 return qe_invalid;
20015 }
20016 }
20017 64 }
20018
20019
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(!p_getc(&temp_zinit.msg_more_x,f))
20020 {
20021 return qe_invalid;
20022 }
20023
20024
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(!p_getc(&temp_zinit.msg_more_y,f))
20025 {
20026 return qe_invalid;
20027 }
20028
20029
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(!p_getc(&subscr_mode,f))
20030 return qe_invalid;
20031
20032 //old only
20033
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
285 if((Header->zelda_version == 0x192)&&(Header->build<174))
20034 {
20035
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
20036 {
20037
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&temp_zinit.boss_key[i],f))
20038 {
20039 return qe_invalid;
20040 }
20041 128 }
20042 4 }
20043
20044
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
285 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20045 {
20046
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 221 times.
281 if(s_version <= 10)
20047 {
20048
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
20049 {
20050 return qe_invalid;
20051 }
20052
20053 60 temp_zinit.start_dmap = (word)tempbyte;
20054 60 }
20055 else
20056 {
20057
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.start_dmap,f))
20058 {
20059 return qe_invalid;
20060 }
20061 }
20062
20063
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20064 {
20065 return qe_invalid;
20066 }
20067 281 }
20068
20069
4/4
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 204 times.
285 if(s_version>1 && s_version < 29)
20070 {
20071
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_getc(&padding,f))
20072 return qe_invalid;
20073 204 temp_zinit.counter[crARROWS] = padding;
20074
20075
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(!p_getc(&padding,f))
20076 return qe_invalid;
20077 204 temp_zinit.mcounter[crARROWS] = padding;
20078 204 }
20079
20080
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 221 times.
285 if(s_version>2)
20081 {
20082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221 times.
221 if(s_version <= 10)
20083 {
20084 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20085 {
20086 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20087 {
20088 return qe_invalid;
20089 }
20090 }
20091 }
20092 else
20093 {
20094
2/2
✓ Branch 0 taken 113152 times.
✓ Branch 1 taken 221 times.
113373 for(int32_t i=0; i<MAXLEVELS; i++)
20095 {
20096
1/2
✓ Branch 0 taken 113152 times.
✗ Branch 1 not taken.
113152 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20097 {
20098 return qe_invalid;
20099 }
20100 113152 }
20101 }
20102 221 }
20103
20104
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 221 times.
285 if(s_version>3)
20105 {
20106
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20107 {
20108 return qe_invalid;
20109 }
20110
20111
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20112 {
20113 return qe_invalid;
20114 }
20115
20116
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20117 {
20118 return qe_invalid;
20119 }
20120
20121
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20122 {
20123 return qe_invalid;
20124 }
20125
20126
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20127 {
20128 return qe_invalid;
20129 }
20130
20131
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20132 {
20133 return qe_invalid;
20134 }
20135
20136
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20137 {
20138 return qe_invalid;
20139 }
20140
20141
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.ss_flags,f))
20142 {
20143 return qe_invalid;
20144 }
20145
20146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221 times.
221 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221 times.
221 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20148 221 }
20149
20150
3/4
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 221 times.
✗ Branch 3 not taken.
285 if(s_version>4 && s_version<15)
20151 {
20152 if(!p_getc(&moving_fairy_hearts,f))
20153 {
20154 return qe_invalid;
20155 }
20156
20157 if(!p_getc(&moving_fairy_heart_percent,f))
20158 {
20159 return qe_invalid;
20160 }
20161 }
20162
20163
3/4
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 221 times.
✗ Branch 3 not taken.
285 if(s_version>5 && s_version < 10)
20164 {
20165 if(!p_getc(&temp,f))
20166 {
20167 return qe_invalid;
20168 }
20169
20170 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20171 }
20172
20173
3/4
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 221 times.
✗ Branch 3 not taken.
285 if(s_version>6 && s_version<15)
20174 {
20175 if(!p_getc(&stationary_fairy_hearts,f))
20176 {
20177 return qe_invalid;
20178 }
20179
20180 if(!p_getc(&stationary_fairy_heart_percent,f))
20181 {
20182 return qe_invalid;
20183 }
20184
20185 if(!p_getc(&moving_fairy_magic,f))
20186 {
20187 return qe_invalid;
20188 }
20189
20190 if(!p_getc(&moving_fairy_magic_percent,f))
20191 {
20192 return qe_invalid;
20193 }
20194
20195 if(!p_getc(&stationary_fairy_magic,f))
20196 {
20197 return qe_invalid;
20198 }
20199
20200 if(!p_getc(&stationary_fairy_magic_percent,f))
20201 {
20202 return qe_invalid;
20203 }
20204
20205 if(!p_getc(&blue_potion_hearts,f))
20206 {
20207 return qe_invalid;
20208 }
20209
20210 if(!p_getc(&blue_potion_heart_percent,f))
20211 {
20212 return qe_invalid;
20213 }
20214
20215 if(!p_getc(&red_potion_hearts,f))
20216 {
20217 return qe_invalid;
20218 }
20219
20220 if(!p_getc(&red_potion_heart_percent,f))
20221 {
20222 return qe_invalid;
20223 }
20224
20225 if(!p_getc(&blue_potion_magic,f))
20226 {
20227 return qe_invalid;
20228 }
20229
20230 if(!p_getc(&blue_potion_magic_percent,f))
20231 {
20232 return qe_invalid;
20233 }
20234
20235 if(!p_getc(&red_potion_magic,f))
20236 {
20237 return qe_invalid;
20238 }
20239
20240 if(!p_getc(&red_potion_magic_percent,f))
20241 {
20242 return qe_invalid;
20243 }
20244 }
20245
20246
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 221 times.
285 if(s_version>6)
20247
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_getc(&padding,f))
20248 return qe_invalid;
20249
20250
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 221 times.
285 if(s_version>7)
20251 {
20252
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_getc(&padding,f))
20253 {
20254 return qe_invalid;
20255 }
20256 221 }
20257
20258
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 221 times.
285 if(s_version>8)
20259 {
20260
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20261 {
20262 return qe_invalid;
20263 }
20264
20265
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20266 {
20267 return qe_invalid;
20268 }
20269 221 }
20270
20271
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 64 times.
285 if(s_version>16)
20272 {
20273
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_getc(&tempbyte,f))
20274 {
20275 return qe_invalid;
20276 }
20277 221 temp_zinit.gravity = tempbyte*100;
20278
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_igetw(&temp_zinit.terminalv,f))
20279 {
20280 return qe_invalid;
20281 }
20282
20283
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_getc(&temp_zinit.msg_speed,f))
20284 {
20285 return qe_invalid;
20286 }
20287
20288
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_getc(&padding,f))
20289 {
20290 return qe_invalid;
20291 }
20292
20293
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20294 {
20295 return qe_invalid;
20296 }
20297 221 }
20298
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20299 12 temp_zinit.msg_speed = 0;
20300
20301
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 221 times.
285 if(s_version>17)
20302 {
20303
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20304 {
20305 return qe_invalid;
20306 }
20307 221 }
20308
20309 //expaned init data for larger values in 2.55
20310
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 17 times.
285 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20311 {
20312
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20313 {
20314 return qe_invalid;
20315 }
20316
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20317 {
20318 return qe_invalid;
20319 }
20320
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20321 {
20322 return qe_invalid;
20323 }
20324
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20325 {
20326 return qe_invalid;
20327 }
20328
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20329 {
20330 return qe_invalid;
20331 }
20332
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20333 {
20334 return qe_invalid;
20335 }
20336
20337 17 }
20338
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 268 times.
285 if ( s_version >= 20 )
20339 {
20340
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroStep,f))
20341 {
20342 return qe_invalid;
20343 }
20344 17 }
20345 else
20346 {
20347 268 temp_zinit.heroStep = 150; //1.5 pixels per frame
20348 }
20349
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 268 times.
285 if ( s_version >= 21 )
20350 {
20351
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20352 {
20353 return qe_invalid;
20354 }
20355 17 }
20356 else
20357 {
20358 268 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20359 }
20360 //old only
20361
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
285 if((Header->zelda_version == 0x192)&&(Header->build<174))
20362 {
20363 byte items2;
20364
20365
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20366 {
20367 return qe_invalid;
20368 }
20369
20370 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20371 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20372 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20373 4 }
20374
20375
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 5 times.
285 if(Header->zelda_version < 0x193)
20376 {
20377
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20378 {
20379
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20380 {
20381 return qe_invalid;
20382 }
20383 480 }
20384
20385 //new only
20386
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20387 {
20388
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20389 {
20390 return qe_invalid;
20391 }
20392
20393
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20394 {
20395 return qe_invalid;
20396 }
20397 1 }
20398 5 }
20399 285 }
20400
20401
3/6
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 221 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
303 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20402 {
20403 //temp_zinit.shield=i_smallshield;
20404 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20405
20406
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20407 82 temp_zinit.set_item(sshieldid, true);
20408 82 }
20409
20410
5/6
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 280 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
303 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20411 {
20412 18 temp_zinit.mcounter[crLIFE]=3;
20413 18 temp_zinit.counter[crLIFE]=3;
20414 18 temp_zinit.cont_heart=3;
20415 18 temp_zinit.mcounter[crBOMBS]=8;
20416 18 }
20417
20418
5/6
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 280 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
303 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20419 {
20420 18 sword_hearts[0]=0;
20421 18 sword_hearts[1]=5;
20422 18 sword_hearts[2]=12;
20423 18 sword_hearts[3]=21;
20424 18 }
20425
20426
5/6
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 280 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
303 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20427 {
20428 18 temp_zinit.last_map=0;
20429 18 temp_zinit.last_screen=0;
20430 18 }
20431
20432
5/6
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 280 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
303 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20433 {
20434 18 temp_zinit.mcounter[crMAGIC]=0;
20435 18 temp_zinit.counter[crMAGIC]=0;
20436 18 temp_zinit.magicdrainrate = 2;
20437 18 }
20438
20439
5/6
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 280 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
303 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20440 {
20441
20442
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20443 {
20444 72 beam_hearts[x]=100;
20445 72 }
20446
20447
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20448 {
20449 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20450 72 set_qr(qr_LENSHINTS+i,0);
20451 72 }
20452
20453
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20454 {
20455 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20456 72 }
20457
20458 18 set_qr(qr_HIDECARRIEDITEMS,0);
20459 18 hookshot_links=100;
20460 18 temp_zinit.msg_more_x=224;
20461 18 temp_zinit.msg_more_y=64;
20462 18 }
20463
20464 // Okay, let's put these legacy values into itemsbuf.
20465
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 82 times.
303 if(s_version < 15)
20466
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
20467 {
20468
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
20469 {
20470 case iFairyStill:
20471 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
20472 82 itemsbuf[i].misc2 = stationary_fairy_magic;
20473 82 itemsbuf[i].misc3 = 0;
20474
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20475
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20476 82 break;
20477
20478 case iFairyMoving:
20479 82 itemsbuf[i].misc1 = moving_fairy_hearts;
20480 82 itemsbuf[i].misc2 = moving_fairy_magic;
20481 82 itemsbuf[i].misc3 = 50;
20482
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20483
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20484 82 break;
20485
20486 case iRPotion:
20487 82 itemsbuf[i].misc1 = red_potion_hearts;
20488 82 itemsbuf[i].misc2 = red_potion_magic;
20489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20491 82 break;
20492
20493 case iBPotion:
20494 82 itemsbuf[i].misc1 = blue_potion_hearts;
20495 82 itemsbuf[i].misc2 = blue_potion_magic;
20496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20498 82 break;
20499
20500 case iSword:
20501 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
20502 82 itemsbuf[i].misc1 = beam_hearts[0];
20503 82 itemsbuf[i].misc2 = beam_power[0];
20504 // It seems that item_flag1 was already added by reset_itembuf()...
20505 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
20506 82 break;
20507
20508 case iWSword:
20509 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
20510 82 itemsbuf[i].misc1 = beam_hearts[1];
20511 82 itemsbuf[i].misc2 = beam_power[1];
20512 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
20513 82 break;
20514
20515 case iMSword:
20516 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
20517 82 itemsbuf[i].misc1 = beam_hearts[2];
20518 82 itemsbuf[i].misc2 = beam_power[2];
20519 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
20520 82 break;
20521
20522 case iXSword:
20523 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
20524 82 itemsbuf[i].misc1 = beam_hearts[3];
20525 82 itemsbuf[i].misc2 = beam_power[3];
20526 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
20527 82 break;
20528
20529 case iHookshot:
20530 82 itemsbuf[i].misc1 = hookshot_length;
20531 82 itemsbuf[i].misc2 = hookshot_links;
20532 82 break;
20533
20534 case iLongshot:
20535 82 itemsbuf[i].misc1 = longshot_length;
20536 82 itemsbuf[i].misc2 = longshot_links;
20537 82 break;
20538 }
20539 21074 }
20540
20541
6/6
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 280 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
303 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20542 {
20543 //was new subscreen rule
20544 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20545 22 set_qr(qr_FREEFORM,0);
20546 22 }
20547
20548
5/6
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 280 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
303 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20549 {
20550 23 temp_zinit.start_dmap=0;
20551 23 }
20552
20553
5/6
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 280 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
303 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20554 {
20555 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20556 23 }
20557
20558
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 221 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
303 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20559 {
20560 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20561 temp_zinit.mcounter[crMONEY]=999;
20562 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20563 }
20564
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 6 times.
303 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20565 {
20566 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20567 6 temp_zinit.mcounter[crBOMBS] = 8;
20568 6 }
20569 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20570 //time to ensure that we port all new values properly:
20571
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 82 times.
303 if(Header->zelda_version < 0x250)
20572 {
20573
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20574 82 }
20575
20576
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 286 times.
303 if(s_version > 21)
20577 {
20578
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hp_per_heart,f))
20579 {
20580 return qe_invalid;
20581 }
20582
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magic_per_block,f))
20583 {
20584 return qe_invalid;
20585 }
20586
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20587 {
20588 return qe_invalid;
20589 }
20590
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20591 {
20592 return qe_invalid;
20593 }
20594 17 }
20595 else
20596 {
20597 286 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20598 286 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20599 286 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20600 286 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20601 }
20602
20603
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 17 times.
303 if(s_version > 22)
20604 {
20605
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.counter[q],f))
20607 return qe_invalid;
20608
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.mcounter[q],f))
20610 return qe_invalid;
20611 17 }
20612
20613
20614
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 286 times.
303 if(s_version > 23)
20615 {
20616
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_type,f))
20617 {
20618 return qe_invalid;
20619 }
20620
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_arg,f))
20621 {
20622 return qe_invalid;
20623 }
20624
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_percent,f))
20625 {
20626 return qe_invalid;
20627 }
20628
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.def_lightrad,f))
20629 {
20630 return qe_invalid;
20631 }
20632
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.transdark_percent,f))
20633 {
20634 return qe_invalid;
20635 }
20636 17 }
20637 else
20638 {
20639 286 temp_zinit.dither_type = 0;
20640 286 temp_zinit.dither_arg = 0;
20641 286 temp_zinit.dither_percent = 20;
20642 286 temp_zinit.def_lightrad = 24;
20643 286 temp_zinit.transdark_percent = 0;
20644 }
20645
20646
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 286 times.
303 if(s_version > 24)
20647 {
20648
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.darkcol,f))
20649 {
20650 return qe_invalid;
20651 }
20652 17 }
20653 else
20654 {
20655 286 temp_zinit.darkcol = BLACK;
20656 }
20657
20658
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 17 times.
303 if(s_version > 25)
20659 {
20660
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.gravity,f))
20661 {
20662 return qe_invalid;
20663 }
20664
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.swimgravity,f))
20665 {
20666 return qe_invalid;
20667 }
20668 17 }
20669
20670
20671
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 286 times.
303 if(s_version > 26)
20672 {
20673
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20674 {
20675 return qe_invalid;
20676 }
20677
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20678 {
20679 return qe_invalid;
20680 }
20681
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20682 {
20683 return qe_invalid;
20684 }
20685 17 }
20686 else
20687 {
20688 286 temp_zinit.heroSideswimUpStep = 150;
20689 286 temp_zinit.heroSideswimSideStep = 100;
20690 286 temp_zinit.heroSideswimDownStep = 75;
20691 }
20692
20693
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 286 times.
303 if(s_version > 27)
20694 {
20695
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20696 {
20697 return qe_invalid;
20698 }
20699 17 }
20700 else
20701 {
20702 286 temp_zinit.exitWaterJump = 0;
20703 }
20704
20705
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 286 times.
303 if(s_version > 29)
20706 {
20707
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20708 {
20709 return qe_invalid;
20710 }
20711 17 }
20712 else
20713 {
20714 286 temp_zinit.bunny_ltm = 0;
20715 }
20716
20717
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 286 times.
303 if(s_version > 30)
20718 {
20719
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.switchhookstyle,f))
20720 {
20721 return qe_invalid;
20722 }
20723 17 }
20724 else
20725 {
20726 286 temp_zinit.switchhookstyle = 1;
20727 }
20728
20729
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 17 times.
303 if(s_version > 31)
20730 {
20731
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magicdrainrate,f))
20732 {
20733 return qe_invalid;
20734 }
20735 17 }
20736
20737 303 temp_zinit.clear_genscript();
20738
2/2
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 12 times.
303 if(s_version > 32)
20739 {
20740 12 word numgenscript = 0;
20741
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&numgenscript,f))
20742 return qe_invalid;
20743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (numgenscript > NUMSCRIPTSGENERIC)
20744 return qe_invalid;
20745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 for(auto q = 1; q < numgenscript; ++q)
20746 {
20747 if(!p_getc(&tempbyte,f))
20748 return qe_invalid;
20749 if(!(tempbyte&2))
20750 continue;
20751 temp_zinit.gen_doscript.set(q, tempbyte&1);
20752 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20753 return qe_invalid;
20754 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20755 return qe_invalid;
20756 for(auto p = 0; p < 8; ++p)
20757 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20758 return qe_invalid;
20759 dword sz;
20760 if(!p_igetl(&sz,f))
20761 return qe_invalid;
20762 temp_zinit.gen_data[q].resize(sz);
20763 std::vector<int32_t> dummy;
20764 if(!p_getlvec(&dummy,f))
20765 return qe_invalid;
20766 temp_zinit.gen_data[q] = dummy;
20767 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20768 return qe_invalid;
20769 }
20770 12 }
20771
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 6 times.
303 if(s_version > 33)
20772 {
20773
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20774 return qe_invalid;
20775
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_div,f))
20776 return qe_invalid;
20777 6 }
20778
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 if(s_version > 34)
20779 {
20780 uint32_t num_used_mapscr_data;
20781 if(!p_igetl(&num_used_mapscr_data,f))
20782 return qe_invalid;
20783 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
20784 {
20785 uint32_t sz;
20786 if(!p_igetl(&sz,f))
20787 return qe_invalid;
20788 temp_zinit.screen_data[q].resize(sz);
20789 if(sz)
20790 {
20791 std::vector<int32_t> dummy;
20792 if(!p_getlvec(&dummy,f))
20793 return qe_invalid;
20794 temp_zinit.screen_data[q] = dummy;
20795 }
20796 }
20797 }
20798
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 if (s_version > 35)
20799 if(!p_igetzf(&temp_zinit.shove_offset,f))
20800 return qe_invalid;
20801
20802 303 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
20803 303 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
20804
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 110 times.
303 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
20805 110 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
20806
20807 303 return 0;
20808 303 }
20809 466 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
20810 {
20811 466 zinitdata temp_zinit = {};
20812
20813
3/4
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
466 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
20814
20815 int32_t dummy;
20816 466 word s_version=0;
20817 byte padding;
20818
20819
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 23 times.
466 if(Header->zelda_version > 0x192)
20820 {
20821
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetw(&s_version,f))
20822 return qe_invalid;
20823 443 FFCore.quest_format[vInitData] = s_version;
20824
20825
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!read_deprecated_section_cversion(f))
20826 return qe_invalid;
20827
20828 //section size
20829
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!p_igetl(&dummy,f))
20830 return qe_invalid;
20831 443 }
20832
20833
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 163 times.
466 if(s_version < 37)
20834 {
20835
2/4
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
303 if(auto ret = readinitdata_old(f,Header,s_version,temp_zinit))
20836 return ret;
20837 303 }
20838 else
20839 {
20840 163 subscr_mode = ssdtMAX;
20841
2/2
✓ Branch 0 taken 5216 times.
✓ Branch 1 taken 163 times.
5379 for(int q = 0; q < MAXITEMS/8; ++q)
20842
2/4
✓ Branch 0 taken 5216 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5216 times.
5216 if(!p_getc(&temp_zinit.items[q], f))
20843 return qe_invalid;
20844
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 10432 times.
10595 for(int q = 0; q < MAXLEVELS/8; ++q)
20845 {
20846
2/4
✓ Branch 0 taken 10432 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10432 times.
✗ Branch 3 not taken.
10432 if(!p_getc(&temp_zinit.map[q], f))
20847 return qe_invalid;
20848
2/4
✓ Branch 0 taken 10432 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10432 times.
10432 if(!p_getc(&temp_zinit.compass[q], f))
20849 return qe_invalid;
20850
2/4
✓ Branch 0 taken 10432 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10432 times.
10432 if(!p_getc(&temp_zinit.boss_key[q], f))
20851 return qe_invalid;
20852
2/4
✓ Branch 0 taken 10432 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10432 times.
✗ Branch 3 not taken.
10432 if(!p_getc(&temp_zinit.mcguffin[q], f))
20853 return qe_invalid;
20854 10432 }
20855
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getbvec(&temp_zinit.level_keys, f))
20856 return qe_invalid;
20857 byte num_counters;
20858
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&num_counters,f))
20859 return qe_invalid;
20860
2/2
✓ Branch 0 taken 17441 times.
✓ Branch 1 taken 163 times.
17604 for(int q = 0; q < num_counters; ++q)
20861
2/4
✓ Branch 0 taken 17441 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17441 times.
17441 if(!p_igetw(&temp_zinit.counter[q],f))
20862 return qe_invalid;
20863
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 17441 times.
17604 for(int q = 0; q < num_counters; ++q)
20864
2/4
✓ Branch 0 taken 17441 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17441 times.
17441 if(!p_igetw(&temp_zinit.mcounter[q],f))
20865 return qe_invalid;
20866
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.bomb_ratio,f))
20867 return qe_invalid;
20868
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.hcp,f))
20869 return qe_invalid;
20870
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20871 return qe_invalid;
20872
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetw(&temp_zinit.cont_heart,f))
20873 return qe_invalid;
20874
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.hp_per_heart,f))
20875 return qe_invalid;
20876
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.magic_per_block,f))
20877 return qe_invalid;
20878
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20879 return qe_invalid;
20880
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20881 return qe_invalid;
20882
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.dither_type,f))
20883 return qe_invalid;
20884
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.dither_arg,f))
20885 return qe_invalid;
20886
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.dither_percent,f))
20887 return qe_invalid;
20888
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.def_lightrad,f))
20889 return qe_invalid;
20890
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.transdark_percent,f))
20891 return qe_invalid;
20892
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.darkcol,f))
20893 return qe_invalid;
20894
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetl(&temp_zinit.ss_grid_x,f))
20895 return qe_invalid;
20896
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetl(&temp_zinit.ss_grid_y,f))
20897 return qe_invalid;
20898
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
20899 return qe_invalid;
20900
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
20901 return qe_invalid;
20902
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetl(&temp_zinit.ss_grid_color,f))
20903 return qe_invalid;
20904
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
20905 return qe_invalid;
20906
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
20907 return qe_invalid;
20908
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetl(&temp_zinit.ss_flags,f))
20909 return qe_invalid;
20910
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getbitstr(&temp_zinit.flags,f))
20911 return qe_invalid;
20912
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.last_map,f))
20913 return qe_invalid;
20914
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.last_screen,f))
20915 return qe_invalid;
20916
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.msg_more_x,f))
20917 return qe_invalid;
20918
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.msg_more_y,f))
20919 return qe_invalid;
20920
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20921 return qe_invalid;
20922
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.msg_speed,f))
20923 return qe_invalid;
20924
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetl(&temp_zinit.gravity,f))
20925 return qe_invalid;
20926
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetl(&temp_zinit.swimgravity,f))
20927 return qe_invalid;
20928
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetw(&temp_zinit.terminalv,f))
20929 return qe_invalid;
20930
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.hero_swim_speed,f))
20931 return qe_invalid;
20932
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20933 return qe_invalid;
20934
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.hero_swim_div,f))
20935 return qe_invalid;
20936
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20937 return qe_invalid;
20938
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20939 return qe_invalid;
20940
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20941 return qe_invalid;
20942
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20943 return qe_invalid;
20944
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetw(&temp_zinit.heroStep,f))
20945 return qe_invalid;
20946
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20947 return qe_invalid;
20948
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20949 return qe_invalid;
20950
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20951 return qe_invalid;
20952
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetw(&temp_zinit.start_dmap,f))
20953 return qe_invalid;
20954
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20955 return qe_invalid;
20956
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.switchhookstyle,f))
20957 return qe_invalid;
20958
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.magicdrainrate,f))
20959 return qe_invalid;
20960
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetzf(&temp_zinit.shove_offset,f))
20961 return qe_invalid;
20962
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
20963 return qe_invalid;
20964
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getbmap(&temp_zinit.gen_exitState, f))
20965 return qe_invalid;
20966
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
20967 return qe_invalid;
20968
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getbmap(&temp_zinit.gen_initd, f))
20969 return qe_invalid;
20970
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
20971 return qe_invalid;
20972
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getbmap(&temp_zinit.gen_data, f))
20973 return qe_invalid;
20974
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getbmap(&temp_zinit.screen_data, f))
20975 return qe_invalid;
20976
1/2
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
163 if (s_version >= 38)
20977 {
20978
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
20979 return qe_invalid;
20980
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if (!p_getc(&temp_zinit.spriteflickercolor, f))
20981 return qe_invalid;
20982
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if (!p_getc(&temp_zinit.spriteflickertransp, f))
20983 return qe_invalid;
20984 163 }
20985
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 28 times.
163 if(s_version >= 39)
20986
2/4
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
135 if(!p_igetzf(&temp_zinit.air_drag, f))
20987 return qe_invalid;
20988
20989 // TODO: this first branch can likely be removed, as it only fixes an issues
20990 // that existed for a handful of temporary z3 builds (and active users of that
20991 // fork would have been updating often, beyond s_version 40).
20992
3/4
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 135 times.
163 if (Header->is_z3 && s_version == 40)
20993 {
20994 if(!p_getc(&temp_zinit.region_mapping, f))
20995 return qe_invalid;
20996 }
20997 else
20998 {
20999
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 28 times.
163 if(s_version >= 40)
21000 {
21001
2/4
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
135 if(!p_igetw(&temp_zinit.light_wave_rate, f))
21002 return qe_invalid;
21003
2/4
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
135 if(!p_igetw(&temp_zinit.light_wave_size, f))
21004 return qe_invalid;
21005 135 }
21006
21007
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 28 times.
163 if(s_version >= 41)
21008 {
21009
2/4
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
135 if(!p_getc(&temp_zinit.region_mapping, f))
21010 return qe_invalid;
21011 135 }
21012 }
21013 }
21014
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 if (should_skip)
21015 return 0;
21016
21017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if(loading_tileset_flags & TILESET_CLEARMAPS)
21018 {
21019 temp_zinit.last_map = 0;
21020 temp_zinit.last_screen = 0;
21021 temp_zinit.screen_data.clear();
21022 }
21023
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 temp_zinit.normalize();
21024
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 zinit = temp_zinit;
21025
21026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466 times.
466 if(zinit.heroAnimationStyle==las_zelda3slow)
21027 {
21028 hero_animation_speed=2;
21029 }
21030 else
21031 {
21032 466 hero_animation_speed=1;
21033 }
21034
21035 466 return 0;
21036 466 }
21037
21038 /*
21039 void setupitemdropsets()
21040 {
21041 for(int32_t i=0; i<isMAX; i++)
21042 {
21043 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21044 }
21045 }
21046 */
21047
21048 407 int32_t readitemdropsets(PACKFILE *f, int32_t version)
21049 {
21050
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 23 times.
407 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21051
21052 dword dummy_dword;
21053 407 word item_drop_sets_to_read=0;
21054 item_drop_object tempitemdrop;
21055 407 word s_version=0;
21056
21057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 407 times.
407 if (!should_skip)
21058
2/2
✓ Branch 0 taken 104192 times.
✓ Branch 1 taken 407 times.
104599 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21059 {
21060 104192 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21061 104599 }
21062
21063
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 23 times.
407 if(version > 0x192)
21064 {
21065 384 item_drop_sets_to_read=0;
21066
21067 //section version info
21068
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetw(&s_version,f))
21069 {
21070 return qe_invalid;
21071 }
21072
21073 384 FFCore.quest_format[vItemDropsets] = s_version;
21074
21075
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
21076 {
21077 return qe_invalid;
21078 }
21079
21080 //section size
21081
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&dummy_dword,f))
21082 {
21083 return qe_invalid;
21084 }
21085
21086 //finally... section data
21087
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetw(&item_drop_sets_to_read,f))
21088 {
21089 return qe_invalid;
21090 }
21091
21092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if (item_drop_sets_to_read > MAXITEMDROPSETS)
21093 {
21094 return qe_invalid;
21095 }
21096 384 }
21097 else
21098 {
21099 23 init_item_drop_sets();
21100 }
21101
21102
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 384 times.
407 if(s_version>=1)
21103 {
21104
2/2
✓ Branch 0 taken 5831 times.
✓ Branch 1 taken 384 times.
6215 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21105 {
21106
1/2
✓ Branch 0 taken 5831 times.
✗ Branch 1 not taken.
5831 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21107 {
21108 return qe_invalid;
21109 }
21110
21111
2/2
✓ Branch 0 taken 58310 times.
✓ Branch 1 taken 5831 times.
64141 for(int32_t j=0; j<10; ++j)
21112 {
21113
1/2
✓ Branch 0 taken 58310 times.
✗ Branch 1 not taken.
58310 if(!p_igetw(&tempitemdrop.item[j],f))
21114 {
21115 return qe_invalid;
21116 }
21117 58310 }
21118
21119
2/2
✓ Branch 0 taken 64141 times.
✓ Branch 1 taken 5831 times.
69972 for(int32_t j=0; j<11; ++j)
21120 {
21121
1/2
✓ Branch 0 taken 64141 times.
✗ Branch 1 not taken.
64141 if(!p_igetw(&tempitemdrop.chance[j],f))
21122 {
21123 return qe_invalid;
21124 }
21125 64141 }
21126
21127 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21128 // overrides the quest's set #12.
21129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5831 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5831 if(s_version<2 && i==12)
21130 continue;
21131
21132 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21133
1/4
✓ Branch 0 taken 5831 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5831 if(s_version<2) for(int32_t j=0; j<10; ++j)
21134 {
21135 int32_t it = tempitemdrop.item[j];
21136
21137 if((itemsbuf[it].family == itype_rupee
21138 && ((itemsbuf[it].amount)&0xFFF) == 10)
21139 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21140 {
21141 tempitemdrop.chance[j+1]=0;
21142 }
21143 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21144 {
21145 tempitemdrop.chance[j+1]=0;
21146 }
21147
21148 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21149 if(itemsbuf[it].family == itype_misc)
21150 {
21151 // If a non-gameplay item was selected, then item drop was aborted.
21152 // Reflect this by increasing the 'Nothing' chance accordingly.
21153 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21154 tempitemdrop.chance[j+1]=0;
21155 }
21156 }
21157
21158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5831 times.
5831 if (!should_skip)
21159 5831 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21160 5831 }
21161 384 }
21162
21163 407 return 0;
21164 407 }
21165
21166 384 int32_t readfavorites(PACKFILE *f, int32_t)
21167 {
21168
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21169
21170 int32_t temp_num;
21171 dword dummy_dword;
21172 word num_favorite_combos;
21173 word num_favorite_combo_aliases;
21174 384 word s_version=0;
21175
21176 //section version info
21177
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetw(&s_version,f))
21178 {
21179 return qe_invalid;
21180 }
21181
21182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if (!should_skip)
21183 384 FFCore.quest_format[vFavourites] = s_version;
21184
21185
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!read_deprecated_section_cversion(f))
21186 {
21187 return qe_invalid;
21188 }
21189
21190 //section size
21191
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetl(&dummy_dword,f))
21192 {
21193 return qe_invalid;
21194 }
21195
21196 384 word per_row = FAVORITECOMBO_PER_ROW;
21197 384 word per_page = FAVORITECOMBO_PER_PAGE;
21198
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 169 times.
384 if(s_version >= 3)
21199
1/2
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
169 if(!p_igetw(&per_row,f))
21200 return qe_invalid;
21201
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 163 times.
384 if(s_version >= 4)
21202
1/2
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
163 if(!p_igetw(&per_page,f))
21203 return qe_invalid;
21204 //finally... section data
21205
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_igetw(&num_favorite_combos,f))
21206 {
21207 return qe_invalid;
21208 }
21209
21210 //Hack; port old favorite combos
21211
3/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
384 if(s_version < 3 && num_favorite_combos == 100)
21212 215 per_row = 13;
21213
21214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if (!should_skip)
21215
2/2
✓ Branch 0 taken 483840 times.
✓ Branch 1 taken 384 times.
484224 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21216 484224 favorite_combos[q] = -1;
21217 384 byte favtype = 0;
21218
2/2
✓ Branch 0 taken 27946 times.
✓ Branch 1 taken 384 times.
28330 for(int32_t i=0; i<num_favorite_combos; i++)
21219 {
21220
2/2
✓ Branch 0 taken 6440 times.
✓ Branch 1 taken 21506 times.
27946 if (s_version >= 4)
21221 {
21222
1/2
✓ Branch 0 taken 6440 times.
✗ Branch 1 not taken.
6440 if (!p_getc(&favtype, f))
21223 {
21224 return qe_invalid;
21225 }
21226 6440 }
21227 else
21228 21506 favtype = 0;
21229
1/2
✓ Branch 0 taken 27946 times.
✗ Branch 1 not taken.
27946 if(!p_igetl(&temp_num,f))
21230 {
21231 return qe_invalid;
21232 }
21233
21234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27946 times.
27946 if (should_skip)
21235 continue;
21236
21237
2/2
✓ Branch 0 taken 6440 times.
✓ Branch 1 taken 21506 times.
27946 if(per_row == FAVORITECOMBO_PER_ROW)
21238 {
21239 6440 favorite_combos[i] = temp_num;
21240 6440 favorite_combo_modes[i] = favtype;
21241 6440 }
21242 else
21243 {
21244 21506 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21245 21506 favorite_combos[new_i]=temp_num;
21246 21506 favorite_combo_modes[new_i] = favtype;
21247 }
21248 27946 }
21249
21250 // Discard the separate favorite aliases list from previous versions
21251
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 221 times.
384 if(s_version<4)
21252 {
21253
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if (!p_igetw(&num_favorite_combo_aliases, f))
21254 {
21255 return qe_invalid;
21256 }
21257
21258
2/2
✓ Branch 0 taken 21500 times.
✓ Branch 1 taken 221 times.
21721 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21259 {
21260
1/2
✓ Branch 0 taken 21500 times.
✗ Branch 1 not taken.
21500 if (!p_igetl(&temp_num, f))
21261 {
21262 return qe_invalid;
21263 }
21264 21500 }
21265 221 }
21266
21267 384 word max_combo_cols = 0;
21268 384 word max_mappages = 0;
21269
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 169 times.
384 if(s_version >= 2)
21270 {
21271
1/2
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
169 if(!p_igetw(&max_combo_cols,f))
21272 return qe_invalid;
21273 169 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21274
2/2
✓ Branch 0 taken 676 times.
✓ Branch 1 taken 169 times.
845 for(int q = 0; q < max_combo_cols; ++q)
21275 {
21276
1/2
✓ Branch 0 taken 676 times.
✗ Branch 1 not taken.
676 if(!p_igetl(&tmp,f))
21277 return qe_invalid;
21278
1/2
✓ Branch 0 taken 676 times.
✗ Branch 1 not taken.
676 if(!p_igetl(&tmp2,f))
21279 return qe_invalid;
21280
1/2
✓ Branch 0 taken 676 times.
✗ Branch 1 not taken.
676 if(!p_igetl(&tmp3,f))
21281 return qe_invalid;
21282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 676 times.
676 if(q < MAX_COMBO_COLS)
21283 {
21284 676 First[q] = tmp;
21285 676 combo_alistpos[q] = tmp2;
21286 676 combo_pool_listpos[q] = tmp3;
21287 676 }
21288 676 }
21289
21290
1/2
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
169 if(!p_igetw(&max_mappages,f))
21291 return qe_invalid;
21292
2/2
✓ Branch 0 taken 1521 times.
✓ Branch 1 taken 169 times.
1690 for(int q = 0; q < max_mappages; ++q)
21293 {
21294
1/2
✓ Branch 0 taken 1521 times.
✗ Branch 1 not taken.
1521 if(!p_igetl(&tmp,f))
21295 return qe_invalid;
21296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1521 times.
1521 if(!p_igetl(&tmp2,f))
21297 return qe_invalid;
21298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1521 times.
1521 if(q < MAX_MAPPAGE_BTNS)
21299 {
21300 1521 map_page[q].map = tmp;
21301 1521 map_page[q].screen = tmp2;
21302 1521 }
21303 1521 }
21304 169 }
21305
21306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if (should_skip)
21307 return 0;
21308
21309
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 384 times.
1244 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21310 {
21311 860 First[q] = 0;
21312 860 combo_alistpos[q] = 0;
21313 860 combo_pool_listpos[q] = 0;
21314 860 }
21315
2/2
✓ Branch 0 taken 1935 times.
✓ Branch 1 taken 384 times.
2319 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21316 {
21317 1935 map_page[q].map = 0;
21318 1935 map_page[q].screen = 0;
21319 1935 }
21320
21321 384 return 0;
21322 384 }
21323
21324 /*
21325 switch (ret) {
21326 case 0:
21327 break;
21328
21329 case qe_invalid:
21330 goto invalid;
21331 break;
21332 default:
21333 pack_fclose(f);
21334 if(!oldquest)
21335 delete_file(tmpfilename);
21336 return ret;
21337 break;
21338 }
21339 */
21340
21341 const char *skip_text[skip_max]=
21342 {
21343 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21344 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21345 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21346 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21347 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21348 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21349 "skip_favorites"
21350 };
21351
21352
21353 void port250QuestRules(){
21354
21355 portCandleRules(); //Candle
21356 portBombRules();
21357
21358 }
21359
21360 void portCandleRules()
21361 {
21362 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21363 //itemdata itemsbuf;
21364 for ( int32_t q = 0; q < MAXITEMS; q++ )
21365 {
21366 if ( itemsbuf[q].family == itype_candle )
21367 {
21368 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21369 else itemsbuf[q].flags &= ~ item_flag2;
21370 }
21371 }
21372 }
21373
21374 void portBombRules()
21375 {
21376 bool hurtshero = get_qr(qr_OUCHBOMBS);
21377 //itemdata itemsbuf;
21378 for ( int32_t q = 0; q < MAXITEMS; q++ )
21379 {
21380 if ( itemsbuf[q].family == itype_bomb )
21381 {
21382 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21383 else itemsbuf[q].flags &= ~ item_flag2;
21384 }
21385 }
21386 }
21387
21388 17997 static int section_id_to_enum(int id)
21389 {
21390
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 779 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 779 times.
✓ Branch 4 taken 779 times.
✓ Branch 5 taken 779 times.
✓ Branch 6 taken 696 times.
✓ Branch 7 taken 779 times.
✓ Branch 8 taken 779 times.
✓ Branch 9 taken 779 times.
✓ Branch 10 taken 779 times.
✓ Branch 11 taken 779 times.
✓ Branch 12 taken 779 times.
✓ Branch 13 taken 696 times.
✓ Branch 14 taken 696 times.
✓ Branch 15 taken 779 times.
✓ Branch 16 taken 779 times.
✓ Branch 17 taken 720 times.
✓ Branch 18 taken 696 times.
✓ Branch 19 taken 696 times.
✓ Branch 20 taken 696 times.
✓ Branch 21 taken 779 times.
✓ Branch 22 taken 779 times.
✓ Branch 23 taken 720 times.
✓ Branch 24 taken 696 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
17997 switch (id)
21391 {
21392 case ID_HEADER: return skip_header;
21393 779 case ID_RULES: return skip_rules;
21394 779 case ID_STRINGS: return skip_strings;
21395 779 case ID_MISC: return skip_misc;
21396 779 case ID_TILES: return skip_tiles;
21397 779 case ID_COMBOS: return skip_combos;
21398 696 case ID_COMBOALIASES: return skip_comboaliases;
21399 779 case ID_CSETS: return skip_csets;
21400 779 case ID_MAPS: return skip_maps;
21401 779 case ID_DMAPS: return skip_dmaps;
21402 779 case ID_DOORS: return skip_doors;
21403 779 case ID_ITEMS: return skip_items;
21404 779 case ID_WEAPONS: return skip_weapons;
21405 696 case ID_COLORS: return skip_colors;
21406 696 case ID_ICONS: return skip_icons;
21407 779 case ID_INITDATA: return skip_initdata;
21408 779 case ID_GUYS: return skip_guys;
21409 720 case ID_HEROSPRITES: return skip_herosprites;
21410 696 case ID_SUBSCREEN: return skip_subscreens;
21411 696 case ID_FFSCRIPT: return skip_ffscript;
21412 696 case ID_SFX: return skip_sfx;
21413 779 case ID_MIDIS: return skip_midis;
21414 779 case ID_CHEATS: return skip_cheats;
21415 720 case ID_ITEMDROPSETS: return skip_itemdropsets;
21416 696 case ID_FAVORITES: return skip_favorites;
21417 case ID_ZINFO: return skip_zinfo;
21418 }
21419
21420 return -1;
21421 17997 }
21422
21423 17589 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21424 {
21425 17589 int section_enum = section_id_to_enum(section_id);
21426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17589 times.
17589 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21427
2/2
✓ Branch 0 taken 6552 times.
✓ Branch 1 taken 11037 times.
17589 if (skip)
21428 {
21429 word s_version;
21430
1/2
✓ Branch 0 taken 6552 times.
✗ Branch 1 not taken.
6552 if (!p_igetw(&s_version,f))
21431 {
21432 return qe_invalid;
21433 }
21434
21435
1/2
✓ Branch 0 taken 6552 times.
✗ Branch 1 not taken.
6552 if (!read_deprecated_section_cversion(f))
21436 {
21437 return qe_invalid;
21438 }
21439
21440
3/4
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 6240 times.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
6552 if (section_id == ID_RULES && s_version > 16)
21441 {
21442 dword dummy;
21443 if (!p_igetl(&dummy,f))
21444 {
21445 return qe_invalid;
21446 }
21447 }
21448
21449
3/4
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 6240 times.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
6552 if (section_id == ID_FFSCRIPT && s_version >= 18)
21450 {
21451 word dummy;
21452 if (!p_igetw(&dummy,f))
21453 {
21454 return qe_invalid;
21455 }
21456 }
21457
21458 dword section_length;
21459
1/2
✓ Branch 0 taken 6552 times.
✗ Branch 1 not taken.
6552 if (!p_igetl(&section_length,f))
21460 {
21461 return qe_invalid;
21462 }
21463
21464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6552 times.
6552 if (pack_fseek(f, section_length))
21465 {
21466 return qe_invalid;
21467 }
21468
21469
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 6240 times.
6552 if (!pack_feof(f))
21470 {
21471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6240 times.
6240 if (!p_mgetl(&section_id,f))
21472 {
21473 return qe_invalid;
21474 }
21475 6240 }
21476
21477 6552 return qe_cancel;
21478 }
21479
21480 11037 return qe_OK;
21481 17589 }
21482
21483 // TODO: this was copied from zc/zasm_utils.cpp
21484 325 static void _zasm_for_every_script(std::function<void(zasm_script*)> fn)
21485 {
21486 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
21487
21488 325 std::vector<zasm_script*> scripts;
21489
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 scripts.reserve(zasm_scripts.size());
21490
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 466075 times.
466400 for (auto& script : zasm_scripts)
21491
3/4
✓ Branch 0 taken 466075 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9529 times.
✓ Branch 3 taken 456546 times.
466075 if (script->valid())
21492
1/2
✓ Branch 0 taken 9529 times.
✗ Branch 1 not taken.
9529 scripts.push_back(script.get());
21493
21494
2/4
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 325 times.
325 std::for_each(scripts.begin(), scripts.end(), fn);
21495 325 }
21496
21497 466 static bool compat_qr_hide_bottom_pixels(const zquestheader& header)
21498 {
21499 // 2.55.9 or newer?
21500
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 330 times.
466 if (header.compareVer(2, 55, 9) >= 0)
21501 136 return false; // defer to whatever was set
21502
21503 // Only a couple quests take any time (~7ms) on my intel mac to check all the ZASM... cache those.
21504
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 std::string title = header.title;
21505
3/4
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✓ Branch 3 taken 3 times.
330 if (title == "Stellar Seas")
21506 3 return false;
21507
3/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 325 times.
327 if (title == "Yuurand: Tales of the Labyrinth")
21508 2 return true;
21509
21510 // Look for ZASM setting values of 167, 168, etc. This is a sign that the script may be drawing something
21511 // near the old "bottom" of the screen, or is attempting to fill the entire screen with a draw command.
21512 // In these cases, the compat rule must be flipped on. As of writing, 72 quests in the PZC database match
21513 // this query: https://gist.github.com/connorjclark/edd12f84c9aac0c924ed328d3f8efcfa
21514 325 bool found = false;
21515
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
9854 _zasm_for_every_script([&](auto script){
21516
2/2
✓ Branch 0 taken 3064 times.
✓ Branch 1 taken 6465 times.
9529 if (found) return;
21517
21518
2/2
✓ Branch 0 taken 6432 times.
✓ Branch 1 taken 27637674 times.
27644106 for (const auto& instr : script->zasm)
21519 {
21520
4/4
✓ Branch 0 taken 24376146 times.
✓ Branch 1 taken 3261528 times.
✓ Branch 2 taken 476809 times.
✓ Branch 3 taken 23899337 times.
27637674 if (!(instr.command == SETV || instr.command == PUSHV)) continue;
21521
21522 3738337 int value = instr.arg2;
21523
9/10
✓ Branch 0 taken 3738334 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3738330 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 3738306 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 3738306 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 3738304 times.
3738337 if (value == 167000000 || value == 168000000 || value == 167870000 || value == 167910000 || value == 168130000)
21524 {
21525 33 found = true;
21526 33 break;
21527 }
21528 }
21529 9529 });
21530
21531 325 return found;
21532 466 }
21533
21534 //Internal function for loadquest wrapper
21535 779 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21536 {
21537 779 DMapEditorLastMaptileUsed = 0;
21538 779 combosread=false;
21539 779 mapsread=false;
21540 779 fixffcs=false;
21541
21542 779 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21543
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21544 {
21545 set_bit(skip_flags, skip_ffscript, 1);
21546 setZScriptVersion(V_FFSCRIPT);
21547 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21548 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21549 do_clear_scripts = true;
21550 }
21551
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 if(loading_tileset_flags & TILESET_CLEARMAPS)
21552 {
21553 set_bit(skip_flags, skip_maps, 1);
21554 }
21555
21556 // show_progress=true;
21557 char tmpfilename[L_tmpnam];
21558 779 temp_name(tmpfilename);
21559 // char percent_done[30];
21560 779 bool catchup=false;
21561 byte tempbyte;
21562 779 word old_map_count=map_count;
21563
21564 779 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21565 779 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21566 779 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21567
21568
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 313 times.
779 if(get_bit(skip_flags, skip_rules))
21569 {
21570 313 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21571 313 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21572 313 }
21573
21574 779 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21575 779 unpack_qrs();
21576 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21577
21578
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 313 times.
779 if(get_bit(skip_flags, skip_midis))
21579 {
21580 313 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21581 313 }
21582
21583
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 313 times.
779 if (!get_bit(skip_flags, skip_maps))
21584 466 Regions = {};
21585
21586
2/2
✓ Branch 0 taken 313 times.
✓ Branch 1 taken 466 times.
779 if(do_clear_scripts)
21587 {
21588 466 zScript.clear();
21589 466 globalmap.clear();
21590 466 genericmap.clear();
21591 466 ffcmap.clear();
21592 466 itemmap.clear();
21593 466 npcmap.clear();
21594 466 ewpnmap.clear();
21595 466 lwpnmap.clear();
21596 466 playermap.clear();
21597 466 dmapmap.clear();
21598 466 screenmap.clear();
21599 466 itemspritemap.clear();
21600 466 comboscriptmap.clear();
21601 466 subscreenmap.clear();
21602
21603
2/2
✓ Branch 0 taken 238126 times.
✓ Branch 1 taken 466 times.
238592 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21604 {
21605 238126 ffcmap[i].clear();
21606 238126 }
21607
21608 466 globalmap[0].slotname = "Slot 1:";
21609 466 globalmap[0].scriptname = "~Init";
21610 466 globalmap[0].update();
21611
21612
2/2
✓ Branch 0 taken 3262 times.
✓ Branch 1 taken 466 times.
3728 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21613 {
21614 3262 globalmap[i].clear();
21615 3262 }
21616
21617
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21618 {
21619 118830 itemmap[i].clear();
21620 118830 }
21621
21622 //new script types -- prevent carrying over to a quest that you load after reading them
21623 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21624
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21625 {
21626 118830 npcmap[i].clear();
21627 118830 }
21628
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21629 {
21630 118830 lwpnmap[i].clear();
21631 118830 }
21632
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21633 {
21634 118830 ewpnmap[i].clear();
21635 118830 }
21636
2/2
✓ Branch 0 taken 1864 times.
✓ Branch 1 taken 466 times.
2330 for(int32_t i=0; i<NUMSCRIPTHERO-1; i++)
21637 {
21638 1864 playermap[i].clear();
21639 1864 }
21640
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21641 {
21642 118830 dmapmap[i].clear();
21643 118830 }
21644
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21645 {
21646 118830 screenmap[i].clear();
21647 118830 }
21648
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21649 {
21650 118830 itemspritemap[i].clear();
21651 118830 }
21652
2/2
✓ Branch 0 taken 238126 times.
✓ Branch 1 taken 466 times.
238592 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21653 {
21654 238126 comboscriptmap[i].clear();
21655 238126 }
21656
2/2
✓ Branch 0 taken 238126 times.
✓ Branch 1 taken 466 times.
238592 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21657 {
21658 238126 genericmap[i].clear();
21659 238126 }
21660
2/2
✓ Branch 0 taken 118830 times.
✓ Branch 1 taken 466 times.
119296 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21661 {
21662 118830 subscreenmap[i].clear();
21663 118830 }
21664
21665 466 reset_scripts();
21666 466 }
21667
21668 779 zquestheader tempheader{};
21669
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 tempheader.filename = filename;
21670
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 zinfo tempzi;
21671
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 tempzi.clear();
21672 779 load_tmp_zi = &tempzi;
21673
21674 // oldquest flag is set when an unencrypted qst file is suspected.
21675 779 bool oldquest = false;
21676 779 int32_t open_error=0;
21677
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21678
21679
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 if (!f)
21680 {
21681 ASSERT(open_error != 0);
21682 return open_error;
21683 }
21684 char zinfofilename[2048];
21685
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 replace_extension(zinfofilename, filename, "zinfo", 2047);
21686 779 int32_t ret=0;
21687
21688 //header
21689
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 box_out("Reading Header...");
21690
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 ret=readheader(f, &tempheader, printmetadata);
21691
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 779 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
779 checkstatus(ret);
21692
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 box_out("okay.");
21693
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 box_eol();
21694
21695
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 599 times.
779 if(read_zinfo)
21696 {
21697
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 box_out("Reading ZInfo - ");
21698
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 177 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
180 box_out(read_ext_zinfo ? "External..." : "Internal...");
21699
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 177 times.
180 if(read_ext_zinfo)
21700 {
21701
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21702
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ret=readzinfo(inf, tempzi, tempheader);
21703
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(inf) pack_fclose(inf);
21704
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3 checkstatus(ret);
21705 3 }
21706 else
21707 {
21708
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 ret=readzinfo(f, tempzi, tempheader);
21709
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
177 checkstatus(ret);
21710 }
21711
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 box_out("okay.");
21712
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 box_eol();
21713 180 }
21714
21715
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 24 times.
779 if(tempheader.zelda_version>=0x193)
21716 {
21717 dword section_id;
21718
21719 //section id
21720
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 if(!p_mgetl(&section_id,f))
21721 {
21722 goto invalid;
21723 }
21724
21725 755 std::set<dword> seen_sections;
21726
21727
3/4
✓ Branch 0 taken 18344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17589 times.
✓ Branch 3 taken 755 times.
18344 while(!pack_feof(f))
21728 {
21729
2/4
✓ Branch 0 taken 17589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17589 times.
✗ Branch 3 not taken.
17589 if (seen_sections.contains(section_id))
21730 goto invalid;
21731
1/2
✓ Branch 0 taken 17589 times.
✗ Branch 1 not taken.
17589 seen_sections.insert(section_id);
21732
21733
3/4
✓ Branch 0 taken 17589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11037 times.
✓ Branch 3 taken 6552 times.
17589 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21734 {
21735
1/2
✓ Branch 0 taken 6552 times.
✗ Branch 1 not taken.
6552 if (retval == qe_cancel)
21736 6552 continue;
21737 checkstatus(retval);
21738 }
21739
21740
24/25
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 443 times.
✓ Branch 2 taken 755 times.
✓ Branch 3 taken 755 times.
✓ Branch 4 taken 443 times.
✓ Branch 5 taken 384 times.
✓ Branch 6 taken 755 times.
✓ Branch 7 taken 443 times.
✓ Branch 8 taken 443 times.
✓ Branch 9 taken 443 times.
✓ Branch 10 taken 443 times.
✓ Branch 11 taken 443 times.
✓ Branch 12 taken 384 times.
✓ Branch 13 taken 384 times.
✓ Branch 14 taken 443 times.
✓ Branch 15 taken 443 times.
✓ Branch 16 taken 384 times.
✓ Branch 17 taken 384 times.
✓ Branch 18 taken 384 times.
✓ Branch 19 taken 384 times.
✓ Branch 20 taken 443 times.
✓ Branch 21 taken 443 times.
✓ Branch 22 taken 384 times.
✓ Branch 23 taken 384 times.
✗ Branch 24 not taken.
11037 switch(section_id)
21741 {
21742 case ID_RULES:
21743
21744 //rules
21745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21746 {
21747 box_out("found.");
21748 box_eol();
21749 catchup=false;
21750 }
21751
21752
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Rules...");
21753
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readrules(f, &tempheader);
21754
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21755
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21756
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21757 443 break;
21758
21759 case ID_STRINGS:
21760
21761 //strings
21762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21763 {
21764 box_out("found.");
21765 box_eol();
21766 catchup=false;
21767 }
21768
21769
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Strings...");
21770
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readstrings(f, &tempheader);
21771
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21772
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21773
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21774 443 break;
21775
21776 case ID_MISC:
21777
21778 //misc data
21779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
755 if(catchup)
21780 {
21781 box_out("found.");
21782 box_eol();
21783 catchup=false;
21784 }
21785
21786
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 box_out("Reading Misc. Data...");
21787
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 ret=readmisc(f, &tempheader, Misc);
21788
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
755 checkstatus(ret);
21789
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 box_out("okay.");
21790
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 box_eol();
21791 755 break;
21792
21793 case ID_TILES:
21794
21795 //tiles
21796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
755 if(catchup)
21797 {
21798 box_out("found.");
21799 box_eol();
21800 catchup=false;
21801 }
21802
21803
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 box_out("Reading Tiles...");
21804
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21805
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
755 checkstatus(ret);
21806
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 box_out("okay.");
21807
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 box_eol();
21808 755 break;
21809
21810 case ID_COMBOS:
21811
21812 //combos
21813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21814 {
21815 box_out("found.");
21816 box_eol();
21817 catchup=false;
21818 }
21819
21820
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Combos...");
21821
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21822 443 combosread=true;
21823
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21824
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21825
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21826 443 break;
21827
21828 case ID_COMBOALIASES:
21829
21830 //combo aliases
21831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
21832 {
21833 box_out("found.");
21834 box_eol();
21835 catchup=false;
21836 }
21837
21838
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Combo Aliases...");
21839
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21840
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
21841
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
21842
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
21843 384 break;
21844
21845 case ID_CSETS:
21846
21847 //color data
21848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
755 if(catchup)
21849 {
21850 box_out("found.");
21851 box_eol();
21852 catchup=false;
21853 }
21854
21855
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 box_out("Reading Color Data...");
21856
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21857
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
755 checkstatus(ret);
21858
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 box_out("okay.");
21859
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 box_eol();
21860 755 break;
21861
21862 case ID_MAPS:
21863
21864 //maps
21865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21866 {
21867 box_out("found.");
21868 box_eol();
21869 catchup=false;
21870 }
21871
21872
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Maps...");
21873
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readmaps(f, &tempheader);
21874 443 mapsread=true;
21875
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21876
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21877
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21878 443 break;
21879
21880 case ID_DMAPS:
21881
21882 //dmaps
21883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21884 {
21885 box_out("found.");
21886 box_eol();
21887 catchup=false;
21888 }
21889
21890
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading DMaps...");
21891
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21892
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21893
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21894
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21895 443 break;
21896
21897 case ID_DOORS:
21898
21899 //door combo sets
21900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21901 {
21902 box_out("found.");
21903 box_eol();
21904 catchup=false;
21905 }
21906
21907
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Doors...");
21908
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readdoorcombosets(f, &tempheader);
21909
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21910
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21911
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21912 443 break;
21913
21914 case ID_ITEMS:
21915
21916 //items
21917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21918 {
21919 box_out("found.");
21920 box_eol();
21921 catchup=false;
21922 }
21923
21924
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Items...");
21925
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21926
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21927
21928
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21929
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21930 443 break;
21931
21932 case ID_WEAPONS:
21933
21934 //weapons
21935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21936 {
21937 box_out("found.");
21938 box_eol();
21939 catchup=false;
21940 }
21941
21942
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Weapons...");
21943
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readweapons(f, &tempheader);
21944
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21945
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21946
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21947 443 break;
21948
21949 case ID_COLORS:
21950
21951 //misc. colors
21952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
21953 {
21954 box_out("found.");
21955 box_eol();
21956 catchup=false;
21957 }
21958
21959
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Misc. Colors...");
21960
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readmisccolors(f, &tempheader, Misc);
21961
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
21962
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
21963
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
21964 384 break;
21965
21966 case ID_ICONS:
21967
21968 //game icons
21969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
21970 {
21971 box_out("found.");
21972 box_eol();
21973 catchup=false;
21974 }
21975
21976
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Game Icons...");
21977
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readgameicons(f, &tempheader, Misc);
21978
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
21979
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
21980
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
21981 384 break;
21982
21983 case ID_INITDATA:
21984
21985 //initialization data
21986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
21987 {
21988 box_out("found.");
21989 box_eol();
21990 catchup=false;
21991 }
21992
21993
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Init. Data...");
21994
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readinitdata(f, &tempheader);
21995
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
21996
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
21997
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
21998
21999
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 443 times.
443 if(!get_bit(skip_flags, skip_subscreens))
22000 {
22001
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 350 times.
443 if(subscr_mode!=ssdtMAX) //not using custom subscreens
22002 {
22003
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 setupsubscreens();
22004
22005
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 93 times.
47709 for(int32_t i=0; i<MAXDMAPS; ++i)
22006 {
22007 47616 int32_t type=DMaps[i].type&dmfTYPE;
22008
2/2
✓ Branch 0 taken 1085 times.
✓ Branch 1 taken 46531 times.
47616 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22009 47616 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22010 47616 }
22011 93 }
22012 443 }
22013
22014
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!get_bit(skip_flags, skip_sfx))
22015 {
22016 443 setupsfx();
22017 443 }
22018
22019
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
443 if(!get_bit(skip_flags, skip_itemdropsets))
22020 {
22021
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 init_item_drop_sets();
22022 443 }
22023
22024
2/4
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 443 times.
443 if(!get_bit(skip_flags, skip_favorites))
22025 {
22026 443 init_favorites();
22027 443 }
22028
22029 443 break;
22030
22031 case ID_GUYS:
22032
22033 //guys
22034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
22035 {
22036 box_out("found.");
22037 box_eol();
22038 catchup=false;
22039 }
22040
22041
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Custom Guy Data...");
22042
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readguys(f, &tempheader);
22043
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
22044
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
22045
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
22046 443 break;
22047
22048 case ID_HEROSPRITES:
22049
22050 //hero sprites
22051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
22052 {
22053 box_out("found.");
22054 box_eol();
22055 catchup=false;
22056 }
22057
22058
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Custom Hero Sprite Data...");
22059
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readherosprites(f, &tempheader);
22060
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
22061
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
22062
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
22063 384 break;
22064
22065 case ID_SUBSCREEN:
22066
22067 //custom subscreens
22068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
22069 {
22070 box_out("found.");
22071 box_eol();
22072 catchup=false;
22073 }
22074
22075
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Custom Subscreen Data...");
22076
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readsubscreens(f);
22077
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
22078
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
22079
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
22080 384 break;
22081
22082 case ID_FFSCRIPT:
22083
22084 //Freeform combo scripts
22085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
22086 {
22087 box_out("found.");
22088 box_eol();
22089 catchup=false;
22090 }
22091
22092
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading FF Script Data...");
22093
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readffscript(f, &tempheader);
22094
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
22095
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
22096
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
22097 384 break;
22098
22099 case ID_SFX:
22100
22101 //SFX data
22102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
22103 {
22104 box_out("found.");
22105 box_eol();
22106 catchup=false;
22107 }
22108
22109
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading SFX Data...");
22110
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readsfx(f, &tempheader);
22111
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
22112
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
22113
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
22114 384 break;
22115
22116 case ID_MIDIS:
22117
22118 //midis
22119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
22120 {
22121 box_out("found.");
22122 box_eol();
22123 catchup=false;
22124 }
22125
22126
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Tunes...");
22127
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readtunes(f, &tempheader, tunes);
22128
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
22129
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
22130
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
22131 443 break;
22132
22133 case ID_CHEATS:
22134
22135 //cheat codes
22136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
443 if(catchup)
22137 {
22138 box_out("found.");
22139 box_eol();
22140 catchup=false;
22141 }
22142
22143
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("Reading Cheat Codes...");
22144
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 ret=readcheatcodes(f, &tempheader);
22145
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
443 checkstatus(ret);
22146
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_out("okay.");
22147
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 box_eol();
22148 443 break;
22149
22150 case ID_ITEMDROPSETS:
22151
22152 //item drop sets
22153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
22154 {
22155 box_out("found.");
22156 box_eol();
22157 catchup=false;
22158 }
22159
22160
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Item Drop Sets...");
22161
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readitemdropsets(f, tempheader.zelda_version);
22162
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
22163
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
22164
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
22165 384 break;
22166
22167 case ID_FAVORITES:
22168
22169 //favorite combos and combo aliases
22170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(catchup)
22171 {
22172 box_out("found.");
22173 box_eol();
22174 catchup=false;
22175 }
22176
22177
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("Reading Favorite Combos...");
22178
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 ret=readfavorites(f, tempheader.zelda_version);
22179
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
384 checkstatus(ret);
22180
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_out("okay.");
22181
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 box_eol();
22182 384 break;
22183
22184 default:
22185 if(!catchup)
22186 {
22187 box_out("Bad token! Searching...");
22188 box_eol();
22189 }
22190
22191 catchup=true;
22192 break;
22193 }
22194
22195
22196
1/2
✓ Branch 0 taken 11037 times.
✗ Branch 1 not taken.
11037 if(catchup)
22197 {
22198 //section id
22199 section_id=(section_id<<8);
22200
22201 if(!p_getc(&tempbyte,f))
22202 {
22203 goto invalid;
22204 }
22205
22206 section_id+=tempbyte;
22207 }
22208
22209 else
22210 {
22211 //section id
22212
3/4
✓ Branch 0 taken 11037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10594 times.
✓ Branch 3 taken 443 times.
11037 if(!pack_feof(f))
22213 {
22214
2/4
✓ Branch 0 taken 10594 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10594 times.
✗ Branch 3 not taken.
10594 if(!p_mgetl(&section_id,f))
22215 {
22216 goto invalid;
22217 }
22218 10594 }
22219 }
22220 }
22221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
755 }
22222 else
22223 {
22224
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22225
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22226
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22227
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22228
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22229
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22230
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22231
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22232
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22233
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22234
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22235
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22236
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22237
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22238
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22239
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22240
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Hero Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1); }},
22241
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1); }},
22242 };
22243
22244 24 legacy_skip_flags = skip_flags;
22245
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22246 {
22247
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22248
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22249
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22250 {
22251 // Nothing to read.
22252
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22253 1 continue;
22254
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22255 1 continue;
22256
22257 // Haven't looked at how to skip these, because we don't need to currently: the only
22258 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22259
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22260 1 continue;
22261
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22262 1 continue;
22263
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22264 1 continue;
22265
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22266 1 continue;
22267
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22268 1 continue;
22269 9 }
22270
22271 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22272 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22273 // read all the sections even if requested to skip some.
22274 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22275 // {
22276 // if (retval == qe_cancel)
22277 // continue;
22278 // checkstatus(retval);
22279 // }
22280
22281
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22282
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22283
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22284
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22285
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22286 }
22287 24 legacy_skip_flags = nullptr;
22288
22289
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22290 {
22291
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22292
22293
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22294 {
22295 11776 int32_t type=DMaps[i].type&dmfTYPE;
22296
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22297 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22298 11776 }
22299 23 }
22300
22301
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22302
22303
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22304 23 setupsfx();
22305
22306
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_favorites))
22307 23 init_favorites();
22308
22309
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
22310
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
22311
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
22312
22313
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 init_spritelists();
22314
22315 // check data
22316
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 if(f)
22317 {
22318
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 pack_fclose(f);
22319 779 }
22320
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 clear_quest_tmpfile();
22321
22322
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 if(!oldquest)
22323 {
22324
2/4
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 779 times.
779 if(exists(tmpfilename))
22325 {
22326 delete_file(tmpfilename);
22327 }
22328 779 }
22329
22330
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 779 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
779 if(fixffcs && combosread && mapsread)
22331 {
22332 for(int32_t i=0; i<map_count; i++)
22333 {
22334 for(int32_t j=0; j<MAPSCRS; j++)
22335 {
22336 int c = TheMaps[(i*MAPSCRS)+j].numFFC();
22337 for(int32_t m=0; m<c; m++)
22338 {
22339 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22340 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
22341 }
22342 }
22343 }
22344 }
22345
22346
3/4
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 313 times.
779 if (!get_bit(skip_flags, skip_rules))
22347 {
22348
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 bool should_hide = compat_qr_hide_bottom_pixels(tempheader);
22349
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 al_trace("Note: qr_HIDE_BOTTOM_8_PIXELS %s via compat rule\n", should_hide ? "enabled" : "disabled");
22350
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 431 times.
466 if (should_hide)
22351
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 set_qr(qr_HIDE_BOTTOM_8_PIXELS, 1);
22352
22353
3/4
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 117 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 349 times.
466 if (FFCore.quest_format[vCompatRule] < 77 && Header->is_z3)
22354 set_qr(qr_LAYER6_STRINGS_OVER_SUBSCREEN, 1);
22355 466 }
22356
22357
7/10
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 715 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 63 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 63 times.
✗ Branch 9 not taken.
779 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22358 {
22359
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 set_qr(qr_CONTFULL_DEP, 0);
22360
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22361 63 zinit.cont_heart=100;
22362 63 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22363 63 }
22364
22365
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 box_out("Done.");
22366
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 box_eol();
22367
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 box_end(false);
22368
22369
3/4
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 312 times.
779 if(!get_bit(skip_flags, skip_header))
22370 {
22371
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 *Header = tempheader;
22372 467 }
22373
3/4
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 313 times.
779 if(!get_bit(skip_flags, skip_zinfo))
22374 {
22375
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 ZI.copyFrom(tempzi);
22376 466 }
22377
22378
3/4
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 313 times.
779 if(get_bit(skip_flags, skip_maps))
22379 {
22380 313 map_count=old_map_count;
22381 313 }
22382
22383
3/4
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 313 times.
✓ Branch 3 taken 466 times.
779 if(get_bit(skip_flags, skip_rules))
22384 {
22385 313 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22386 313 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22387
1/2
✓ Branch 0 taken 313 times.
✗ Branch 1 not taken.
313 unpack_qrs();
22388 313 }
22389
22390
3/4
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 313 times.
✓ Branch 3 taken 466 times.
779 if(get_bit(skip_flags, skip_midis))
22391 {
22392 313 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22393 313 }
22394
22395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779 times.
779 if(loading_tileset_flags & TILESET_CLEARMAPS)
22396 {
22397 TheMaps.clear();
22398 TheMaps.resize(MAPSCRS*1);
22399 map_count = 1;
22400 map_autolayers.clear();
22401 map_autolayers.resize(6*1);
22402 }
22403
22404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779 times.
779 if(loading_tileset_flags & TILESET_CLEARHEADER)
22405 {
22406 memset(Header->password, 0, sizeof(Header->password));
22407 memset(Header->minver, 0, sizeof(Header->minver));
22408 memset(Header->title, 0, sizeof(Header->title));
22409 memset(Header->author, 0, sizeof(Header->author));
22410 memset(Header->version, 0, sizeof(Header->version));
22411 Header->use_keyfile = 0;
22412 Header->dirty_password = false;
22413 cvs_MD5Context ctx;
22414 cvs_MD5Init(&ctx);
22415 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22416 cvs_MD5Final(Header->pwd_hash, &ctx);
22417 }
22418
22419
3/4
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 313 times.
779 if (!get_bit(skip_flags, skip_maps))
22420 {
22421 // Not needed, so release its memory.
22422
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
466 old_combo_pages = {};
22423 466 }
22424
22425 779 return qe_OK;
22426
22427 invalid:
22428 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22429 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22430 box_out("error.");
22431 box_eol();
22432 box_end(true);
22433
22434 pack_fclose(f);
22435
22436 if(!oldquest)
22437 {
22438 if(exists(tmpfilename))
22439 {
22440 delete_file(tmpfilename);
22441 }
22442 }
22443
22444 return qe_invalid;
22445
22446 779 }
22447
22448 static bool _is_loading_quest;
22449
22450 bool is_loading_quest()
22451 {
22452 return _is_loading_quest;
22453 }
22454
22455 312 std::string get_last_loaded_qstpath()
22456 {
22457 312 return last_loaded_qstpath;
22458 }
22459
22460 779 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22461 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22462 bool report, byte qst_num, dword tilesetflags)
22463 {
22464 779 loading_tileset_flags = tilesetflags;
22465 779 const char* basename = get_filename(filename);
22466 779 zapp_reporting_add_breadcrumb("load_quest", basename);
22467 779 zapp_reporting_set_tag("qst.filename", basename);
22468
22469 779 last_loaded_qstpath = filename;
22470 779 loading_qst_name = filename;
22471 779 loading_qst_num = qst_num;
22472 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22473 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22474
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 if (!is_ci())
22475 loadquest_report = report;
22476
22477 779 _is_loading_quest = true;
22478 779 auto start = std::chrono::steady_clock::now();
22479 779 zprint2("Loading qst: %s\n", filename);
22480 779 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22481 779 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22482 779 zprint2("Time to load qst: %d ms\n", load_ms);
22483 779 _is_loading_quest = false;
22484
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 if (ret)
22485 zprint2("Error: %s\n", qst_error[ret]);
22486
22487
1/2
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
779 if(show_progress)
22488 {
22489 if(ret)
22490 {
22491 box_out("-- Error loading quest file! --");
22492 box_out(fmt::format("Error: {}", qst_error[ret]).c_str());
22493 box_end(true);
22494 }
22495 else box_end(false);
22496 }
22497
22498 779 load_tmp_zi = NULL;
22499 779 loading_qst_name = NULL;
22500 779 loadquest_report = false;
22501 779 loading_qst_num = 0;
22502
22503 779 zapp_reporting_set_tag("qst.author", Header->author);
22504 779 zapp_reporting_set_tag("qst.title", Header->title);
22505 779 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22506
22507 779 return ret;
22508 }
22509